diff options
author | Nathan Sidwell <nathan@acm.org> | 1999-09-02 09:21:42 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 1999-09-02 09:21:42 +0000 |
commit | 1b4d752a6422fad640ac6c18ad49a424b02f4849 (patch) | |
tree | 9fc288764a6314905d2b2a86db4fbb86f72faa71 /gcc | |
parent | e6380233ffeef512f5db01c0543a37e68c61cb90 (diff) | |
download | gcc-1b4d752a6422fad640ac6c18ad49a424b02f4849.zip gcc-1b4d752a6422fad640ac6c18ad49a424b02f4849.tar.gz gcc-1b4d752a6422fad640ac6c18ad49a424b02f4849.tar.bz2 |
call.c (build_conditional_expr): Warn on enum mismatches.
* call.c (build_conditional_expr): Warn on enum mismatches.
(convert_arg_to_ellipsis): Move non-pod check to after
conversion.
From-SVN: r29056
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 26 |
2 files changed, 25 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b6721d4..0bf24e0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1999-09-02 Nathan Sidwell <nathan@acm.org> + + * call.c (build_conditional_expr): Warn on enum mismatches. + (convert_arg_to_ellipsis): Move non-pod check to after + conversion. + 1999-09-01 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * gxx.gperf (hash, is_reserved_word): Add prototypes. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 0eefa7f..81e4efb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -2991,6 +2991,18 @@ build_conditional_expr (arg1, arg2, arg3) /* In this case, there is always a common type. */ result_type = type_after_usual_arithmetic_conversions (arg2_type, arg3_type); + + if (TREE_CODE (arg2_type) == ENUMERAL_TYPE + && TREE_CODE (arg3_type) == ENUMERAL_TYPE) + cp_warning ("enumeral mismatch in conditional expression: `%T' vs `%T'", + arg2_type, arg3_type); + else if (extra_warnings + && ((TREE_CODE (arg2_type) == ENUMERAL_TYPE + && !same_type_p (arg3_type, type_promotes_to (arg2_type))) + || (TREE_CODE (arg3_type) == ENUMERAL_TYPE + && !same_type_p (arg2_type, type_promotes_to (arg3_type))))) + cp_warning ("enumeral and non-enumeral type in conditional expression"); + arg2 = perform_implicit_conversion (result_type, arg2); arg3 = perform_implicit_conversion (result_type, arg3); } @@ -3755,13 +3767,6 @@ tree convert_arg_to_ellipsis (arg) tree arg; { - if (! pod_type_p (TREE_TYPE (arg))) - { - /* Undefined behaviour [expr.call] 5.2.2/7. */ - cp_warning ("cannot pass objects of non-POD type `%#T' through `...'", - TREE_TYPE (arg)); - } - if (TREE_CODE (TREE_TYPE (arg)) == REAL_TYPE && (TYPE_PRECISION (TREE_TYPE (arg)) < TYPE_PRECISION (double_type_node))) @@ -3773,6 +3778,13 @@ convert_arg_to_ellipsis (arg) arg = require_complete_type (arg); + if (arg != error_mark_node && ! pod_type_p (TREE_TYPE (arg))) + { + /* Undefined behaviour [expr.call] 5.2.2/7. */ + cp_warning ("cannot pass objects of non-POD type `%#T' through `...'", + TREE_TYPE (arg)); + } + return arg; } |