From 54dcdb88954b1192b004f8b91fc17a42765c20eb Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 12 Sep 2016 20:18:16 +0000 Subject: re PR c++/77496 (ICE in instantiate_type, at cp/class.c:8270) gcc/c-family: 2016-09-12 Bernd Edlinger PR c++/77496 * c-common.c (warn_for_omitted_condop): Also warn for boolean data. gcc/c: 2016-09-12 Bernd Edlinger PR c++/77496 * c-parser.c (c_parser_conditional_expression): Pass the rightmost COMPOUND_EXPR to warn_for_omitted_condop. gcc/cp: 2016-09-12 Bernd Edlinger PR c++/77496 * call.c (build_conditional_expr_1): Call warn_for_omitted_condop. * class.c (instantiate_type): Look through the SAVE_EXPR. gcc/testsuite: 2016-09-12 Bernd Edlinger PR c++/77496 * c-c++-common/warn-ommitted-condop.c: Add more test cases. * g++.dg/ext/pr77496.C: New test. * g++.dg/warn/pr77496.C: New test. From-SVN: r240098 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index a647263..b474de1 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-09-12 Bernd Edlinger + + PR c++/77496 + * c-parser.c (c_parser_conditional_expression): Pass the rightmost + COMPOUND_EXPR to warn_for_omitted_condop. + 2016-09-07 David Malcolm * c-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Use diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 0aba51c..a304424 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -6425,14 +6425,17 @@ c_parser_conditional_expression (c_parser *parser, struct c_expr *after, tree eptype = NULL_TREE; middle_loc = c_parser_peek_token (parser)->location; - pedwarn (middle_loc, OPT_Wpedantic, + pedwarn (middle_loc, OPT_Wpedantic, "ISO C forbids omitting the middle term of a ?: expression"); - warn_for_omitted_condop (middle_loc, cond.value); if (TREE_CODE (cond.value) == EXCESS_PRECISION_EXPR) { eptype = TREE_TYPE (cond.value); cond.value = TREE_OPERAND (cond.value, 0); } + tree e = cond.value; + while (TREE_CODE (e) == COMPOUND_EXPR) + e = TREE_OPERAND (e, 1); + warn_for_omitted_condop (middle_loc, e); /* Make sure first operand is calculated only once. */ exp1.value = c_save_expr (default_conversion (cond.value)); if (eptype) -- cgit v1.1