summaryrefslogtreecommitdiff
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2009-06-19 20:55:27 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2009-06-19 20:55:27 +0000
commitd130ae115657aa4e4c4dab6e56f3c08d44bcdfa8 (patch)
tree1e0b709ce5a70aacdf2f57b1ae07b31bd68bf02e /gcc/c-typeck.c
parent502c4bb950b3f5f0b1089800123acadf595e12b4 (diff)
downloadgcc-d130ae115657aa4e4c4dab6e56f3c08d44bcdfa8.tar.gz
tree-cfg.c (gimple_redirect_edge_and_branch): Change ERROR_MARK to GIMPLE_ERROR_MARK.
./: * tree-cfg.c (gimple_redirect_edge_and_branch): Change ERROR_MARK to GIMPLE_ERROR_MARK. * c-typeck.c (build_conditional_expr): Add op1_original_type and op2_original_type parameters. Warn about using different enum types. * c-parser.c (c_parser_conditional_expression): Pass original types to build_conditional_expr. * c-tree.h (build_conditional_expr): Update declaration. testsuite/: * gcc.dg/Wcxx-compat-18.c: New testcase. From-SVN: r148727
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 0a40a888d53..df1e1718405 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -3770,7 +3770,8 @@ c_mark_addressable (tree exp)
tree
build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
- tree op1, tree op2)
+ tree op1, tree op1_original_type, tree op2,
+ tree op2_original_type)
{
tree type1;
tree type2;
@@ -3843,6 +3844,20 @@ build_conditional_expr (location_t colon_loc, tree ifexp, bool ifexp_bcp,
}
}
+ if (warn_cxx_compat)
+ {
+ tree t1 = op1_original_type ? op1_original_type : TREE_TYPE (orig_op1);
+ tree t2 = op2_original_type ? op2_original_type : TREE_TYPE (orig_op2);
+
+ if (TREE_CODE (t1) == ENUMERAL_TYPE
+ && TREE_CODE (t2) == ENUMERAL_TYPE
+ && TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2))
+ warning_at (colon_loc, OPT_Wc___compat,
+ ("different enum types in conditional is "
+ "invalid in C++: %qT vs %qT"),
+ t1, t2);
+ }
+
/* Quickly detect the usual case where op1 and op2 have the same type
after promotion. */
if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))