public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paolo Carlini <paolo.carlini@oracle.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Jason Merrill <jason@redhat.com>
Subject: [C++ Patch] PR 41769
Date: Fri, 10 Jun 2011 18:42:00 -0000	[thread overview]
Message-ID: <4DF2650A.70906@oracle.com> (raw)

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

Hi,

as it happens, a couple of years ago Johannes filed a PR quite similar 
to 29003 but for function parameters, and we have a similar issue for 
catch clauses too. Patch tested x86_64-linux.

Is it Ok?

Thanks,
Paolo.

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

[-- Attachment #2: CL_41769 --]
[-- Type: text/plain, Size: 251 bytes --]

/cp
2011-06-10  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/29003
	* decl.c (grokdeclarator): Reject operator names in parameters.

/testsuite
2011-06-10  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/29003
	* g++.dg/parse/error39.C: New.

[-- Attachment #3: patch_41769 --]
[-- Type: text/plain, Size: 1265 bytes --]

Index: testsuite/g++.dg/parse/error39.C
===================================================================
--- testsuite/g++.dg/parse/error39.C	(revision 0)
+++ testsuite/g++.dg/parse/error39.C	(revision 0)
@@ -0,0 +1,14 @@
+// PR c++/41769
+
+void f(void operator+()); // { dg-error "declaration" }
+
+void g()
+{
+  try
+    {
+
+    }
+  catch(void operator+()) // { dg-error "declaration" }
+    {
+    }
+}
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 174918)
+++ cp/decl.c	(working copy)
@@ -8441,11 +8441,18 @@ grokdeclarator (const cp_declarator *declarator,
       return error_mark_node;
     }
 
-  if (dname && IDENTIFIER_OPNAME_P (dname)
-      && declspecs->specs[(int)ds_typedef])
+  if (dname && IDENTIFIER_OPNAME_P (dname))
     {
-      error ("declaration of %qD as %<typedef%>", dname);
-      return error_mark_node;
+      if (declspecs->specs[(int)ds_typedef])
+	{
+	  error ("declaration of %qD as %<typedef%>", dname);
+	  return error_mark_node;
+	}
+      else if (decl_context == PARM || decl_context == CATCHPARM)
+	{
+	  error ("declaration of %qD as parameter", dname);
+	  return error_mark_node;
+	}
     }
 
   /* Anything declared one level down from the top level

             reply	other threads:[~2011-06-10 18:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10 18:42 Paolo Carlini [this message]
2011-06-10 18:45 ` 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=4DF2650A.70906@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).