public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: Jason Merrill <jason@redhat.com>,
	       "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [C++ Patch] PR 60955
Date: Thu, 18 Dec 2014 16:44:00 -0000	[thread overview]
Message-ID: <54930173.4030104@oracle.com> (raw)
In-Reply-To: <5492E2BD.1040602@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 421 bytes --]

Hi,

On 12/18/2014 03:20 PM, Jason Merrill wrote:
> On 12/18/2014 06:17 AM, Paolo Carlini wrote:
>> Sure. The below uses the c_inhibit_evaluation_warnings mechanism and
>> passes testing. I wondered if in such cases we could alternately use the
>> warning_sentinel mechanism (moved to cp-tree.h of course) ?
> That would make sense to me.
Good. Then I'm finishing testing the below.

Thanks,
Paolo.

////////////////////

[-- Attachment #2: patch_60955_3 --]
[-- Type: text/plain, Size: 2299 bytes --]

Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 218857)
+++ cp/cp-tree.h	(working copy)
@@ -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.  */
 
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 218857)
+++ cp/pt.c	(working copy)
@@ -14438,16 +14438,6 @@ tsubst_non_call_postfix_expression (tree t, tree a
   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)".  */
 
Index: cp/semantics.c
===================================================================
--- cp/semantics.c	(revision 218857)
+++ cp/semantics.c	(working copy)
@@ -1660,6 +1660,7 @@ force_paren_expr (tree expr)
 	  tree type = unlowered_expr_type (expr);
 	  bool rval = !!(kind & clk_rvalueref);
 	  type = cp_build_reference_type (type, rval);
+	  warning_sentinel s (extra_warnings);
 	  expr = build_static_cast (type, expr, tf_error);
 	  if (expr != error_mark_node)
 	    REF_PARENTHESIZED_P (expr) = true;
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;
+}

  reply	other threads:[~2014-12-18 16:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-10 19:24 Paolo Carlini
2014-12-17 20:37 ` [Ping][C++ " Paolo Carlini
2014-12-17 20:40 ` [C++ " Jason Merrill
2014-12-18 11:22   ` Paolo Carlini
2014-12-18 14:20     ` Jason Merrill
2014-12-18 16:44       ` Paolo Carlini [this message]
2014-12-18 17:23         ` Jason Merrill
2014-12-18 18:00           ` Paolo Carlini
2014-12-22 15:21             ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54930173.4030104@oracle.com \
    --to=paolo.carlini@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).