From: Paolo Carlini Date: Thu, 18 Dec 2014 17:53:55 +0000 (+0000) Subject: re PR c++/60955 (Erroneous warning about taking address of register with std=c++1y) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6e4992ca7811bcb1d3ebe587d06e346c09d72cc1;p=gcc.git re PR c++/60955 (Erroneous warning about taking address of register with std=c++1y) /cp 2014-12-18 Paolo Carlini PR c++/60955 * pt.c (struct warning_sentinel): Move it... * cp-tree.h: ... here. * semantics.c (force_paren_expr): Use it. /testsuite 2014-12-18 Paolo Carlini PR c++/60955 * g++.dg/warn/register-parm-1.C: New. From-SVN: r218871 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e7e2365353e..e22b516ae75 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2014-12-18 Paolo Carlini + + PR c++/60955 + * pt.c (struct warning_sentinel): Move it... + * cp-tree.h: ... here. + * semantics.c (force_paren_expr): Use it. + 2014-12-17 Jason Merrill PR c++/64333 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e0e7690b188..9487e503ae1 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1149,6 +1149,18 @@ struct processing_template_decl_sentinel } }; +/* RAII sentinel to disable certain warnings during template substitution + and elsewhere. */ + +struct warning_sentinel +{ + int &flag; + int val; + warning_sentinel(int& flag, bool suppress=true) + : flag(flag), val(flag) { if (suppress) flag = 0; } + ~warning_sentinel() { flag = val; } +}; + /* The cached class binding level, from the most recently exited class, or NULL if none. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8a663d98c47..9f036846f58 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14438,16 +14438,6 @@ tsubst_non_call_postfix_expression (tree t, tree args, return t; } -/* Sentinel to disable certain warnings during template substitution. */ - -struct warning_sentinel { - int &flag; - int val; - warning_sentinel(int& flag, bool suppress=true) - : flag(flag), val(flag) { if (suppress) flag = 0; } - ~warning_sentinel() { flag = val; } -}; - /* Like tsubst but deals with expressions and performs semantic analysis. FUNCTION_P is true if T is the "F" in "F (ARGS)". */ diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5ad391eda5b..bea3b1fbe68 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1660,6 +1660,9 @@ force_paren_expr (tree expr) tree type = unlowered_expr_type (expr); bool rval = !!(kind & clk_rvalueref); type = cp_build_reference_type (type, rval); + /* This inhibits warnings in, eg, cxx_mark_addressable + (c++/60955). */ + warning_sentinel s (extra_warnings); expr = build_static_cast (type, expr, tf_error); if (expr != error_mark_node) REF_PARENTHESIZED_P (expr) = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4d75d0e04b2..5ad3d9ab82d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-18 Paolo Carlini + + PR c++/60955 + * g++.dg/warn/register-parm-1.C: New. + 2014-12-18 H.J. Lu * gcc.target/i386/amd64-abi-7.c: New tests. diff --git a/gcc/testsuite/g++.dg/warn/register-parm-1.C b/gcc/testsuite/g++.dg/warn/register-parm-1.C new file mode 100644 index 00000000000..44232d3cf41 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/register-parm-1.C @@ -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; +}