From 1b4d752a6422fad640ac6c18ad49a424b02f4849 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 2 Sep 1999 09:21:42 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/call.c | 26 +++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b6721d4d955..0bf24e08095 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +1999-09-02 Nathan Sidwell + + * 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 * gxx.gperf (hash, is_reserved_word): Add prototypes. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 0eefa7f49c0..81e4efb4a39 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; } -- 2.30.2