summaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authoredlinger <edlinger@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-12 20:18:16 +0000
committeredlinger <edlinger@138bc75d-0d04-0410-961f-82ee72b054a4>2016-09-12 20:18:16 +0000
commit7a21b590fb5d96a2a925f2a26ea1f20c89ae070f (patch)
tree06828e718304e9c4c4e9aa0de02496b72d3bff1b /gcc/c
parentd7b41a73a78cbd6f291bf8d4090638057b964c11 (diff)
downloadgcc-7a21b590fb5d96a2a925f2a26ea1f20c89ae070f.tar.gz
gcc/c-family:
2016-09-12 Bernd Edlinger <bernd.edlinger@hotmail.de> PR c++/77496 * c-common.c (warn_for_omitted_condop): Also warn for boolean data. gcc/c: 2016-09-12 Bernd Edlinger <bernd.edlinger@hotmail.de> 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 <bernd.edlinger@hotmail.de> 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 <bernd.edlinger@hotmail.de> 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240098 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c7
2 files changed, 11 insertions, 2 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index a6472638411..b474de193a5 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2016-09-12 Bernd Edlinger <bernd.edlinger@hotmail.de>
+
+ 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 <dmalcolm@redhat.com>
* c-lang.c (LANG_HOOKS_GET_SUBSTRING_LOCATION): Use
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 0aba51c9cde..a3044244f6c 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)