Commit c09c4992 by Bernd Edlinger Committed by Bernd Edlinger

re PR c++/77700 (suspicios code in cp/parser.c)

2016-10-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77700
        * c-common.c (c_common_truthvalue_conversion): Warn also for
        suspicious enum values in boolean context.

cp:
2016-10-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77700
        * parser.c (cp_parser_base_specifier): Fix a warning.

testsuite:
2016-10-07  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR c++/77700
        * c-c++-common/Wint-in-bool-context.c: Update test.

From-SVN: r240867
parent 125f0e39
2016-10-07 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR c++/77700
* c-common.c (c_common_truthvalue_conversion): Warn also for
suspicious enum values in boolean context.
2016-10-06 Jakub Jelinek <jakub@redhat.com>
Implement P0258R2 - helper for C++17
......
......@@ -4590,6 +4590,11 @@ c_common_truthvalue_conversion (location_t location, tree expr)
return expr;
case INTEGER_CST:
if (TREE_CODE (TREE_TYPE (expr)) == ENUMERAL_TYPE
&& !integer_zerop (expr)
&& !integer_onep (expr))
warning_at (location, OPT_Wint_in_bool_context,
"enum constant in boolean context");
return integer_zerop (expr) ? truthvalue_false_node
: truthvalue_true_node;
......
2016-10-07 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR c++/77700
* parser.c (cp_parser_base_specifier): Fix a warning.
2016-10-07 Bernd Schmidt <bschmidt@redhat.com>
PR c++/69733
......
......@@ -23338,7 +23338,7 @@ cp_parser_base_specifier (cp_parser* parser)
cp_parser_nested_name_specifier_opt (parser,
/*typename_keyword_p=*/true,
/*check_dependency_p=*/true,
typename_type,
/*type_p=*/true,
/*is_declaration=*/true);
/* If the base class is given by a qualified name, assume that names
we see are type names or templates, as appropriate. */
2016-10-07 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR c++/77700
* c-c++-common/Wint-in-bool-context.c: Update test.
2016-10-07 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/vrp01.c: Adjust.
......
......@@ -2,6 +2,8 @@
/* { dg-options "-Wint-in-bool-context" } */
/* { dg-do compile } */
enum truth { yes, no, maybe };
int foo (int a, int b)
{
if (a > 0 && a <= (b == 1) ? 1 : 2) /* { dg-warning "boolean context" } */
......@@ -27,5 +29,11 @@ int foo (int a, int b)
for (a = 0; 1 << a; a++); /* { dg-warning "boolean context" } */
if (yes || no || maybe) /* { dg-warning "boolean context" "" { target c++ } } */
return 8;
if (yes || no) /* { dg-bogus "boolean context" } */
return 9;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment