Message ID | 54889DF2.7060704@oracle.com |
---|---|
State | New |
Headers | show |
Hi, gently pinging this.... https://gcc.gnu.org/ml/gcc-patches/2014-12/msg00961.html On 12/10/2014 08:24 PM, Paolo Carlini wrote: > Hi, > > this regression, a spurious warning about taking the address of a > register parameter, happens in C++14 mode due to the use of > force_paren_expr, called by finish_parenthesized_expr, which ends up > calling build_static_cast. Manuel mentioned in the audit trail that > TREE_NO_WARNING can be used for DECLs too, and indeed I noticed today > that we are *already* using it for EXPRs, at the beginning of > finish_parenthesized_expr. I experimented a bit with restricting the > setting, eg, to PARM_DECLs only, but in fact we have an identical > issue for, eg, register VAR_DECLs. Tested x86_64-linux. Thanks, Paolo.
I'm uncomfortable with setting TREE_NO_WARNING on a decl just because we don't want a warning for one particular use of it. How about suppressing warnings across the call to build_static_cast? Jason
Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 218586) +++ cp/semantics.c (working copy) @@ -1674,10 +1674,13 @@ force_paren_expr (tree expr) tree finish_parenthesized_expr (tree expr) { - if (EXPR_P (expr)) - /* This inhibits warnings in c_common_truthvalue_conversion. */ - TREE_NO_WARNING (expr) = 1; + if (expr == error_mark_node) + return error_mark_node; + /* Inhibit warnings in c_common_truthvalue_conversion and in + cxx_mark_addressable. */ + TREE_NO_WARNING (expr) = 1; + if (TREE_CODE (expr) == OFFSET_REF || TREE_CODE (expr) == SCOPE_REF) /* [expr.unary.op]/3 The qualified id of a pointer-to-member must not be Index: cp/typeck.c =================================================================== --- cp/typeck.c (revision 218586) +++ cp/typeck.c (working copy) @@ -6068,7 +6068,8 @@ cxx_mark_addressable (tree exp) ("address of explicit register variable %qD requested", x); return false; } - else if (extra_warnings) + else if (extra_warnings + && !TREE_NO_WARNING (x)) warning (OPT_Wextra, "address requested for %qD, which is declared %<register%>", x); } Index: testsuite/g++.dg/warn/register-parm-1.C =================================================================== --- testsuite/g++.dg/warn/register-parm-1.C (revision 0) +++ testsuite/g++.dg/warn/register-parm-1.C (working copy) @@ -0,0 +1,9 @@ +// PR c++/60955 +// { dg-options "-Wextra" } + +unsigned int erroneous_warning(register int a) { + if ((a) & 0xff) return 1; else return 0; +} +unsigned int no_erroneous_warning(register int a) { + if (a & 0xff) return 1; else return 0; +}