public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 29003
@ 2011-06-09 11:44 Paolo Carlini
  2011-06-09 14:19 ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2011-06-09 11:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jason Merrill

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

Hi,

I tested on x86_64-linux the below patchlet for a long standing 
accepts-invalid. Is it ok for mainline? Or do we want a different error 
message? A somehow tighter check?

Thanks,
Paolo.

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

[-- Attachment #2: CL_29003 --]
[-- Type: text/plain, Size: 249 bytes --]

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

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

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

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

[-- Attachment #3: patch_29003 --]
[-- Type: text/plain, Size: 907 bytes --]

Index: testsuite/g++.dg/parse/error38.C
===================================================================
--- testsuite/g++.dg/parse/error38.C	(revision 0)
+++ testsuite/g++.dg/parse/error38.C	(revision 0)
@@ -0,0 +1,3 @@
+// PR c++/29003
+
+typedef int operator !(); // { dg-error "not allowed" }
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 174838)
+++ cp/decl.c	(working copy)
@@ -8441,6 +8441,13 @@ grokdeclarator (const cp_declarator *declarator,
       return error_mark_node;
     }
 
+  if (dname && IDENTIFIER_OPNAME_P (dname)
+      && declspecs->specs[(int)ds_typedef])
+    {
+      error ("operator name is not allowed");
+      return error_mark_node;
+    }
+
   /* Anything declared one level down from the top level
      must be one of the parameters of a function
      (because the body is at least two levels down).  */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] PR 29003
  2011-06-09 11:44 [C++ Patch] PR 29003 Paolo Carlini
@ 2011-06-09 14:19 ` Jason Merrill
  2011-06-09 14:37   ` Paolo Carlini
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Merrill @ 2011-06-09 14:19 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

On 06/09/2011 06:07 AM, Paolo Carlini wrote:
> I tested on x86_64-linux the below patchlet for a long standing
> accepts-invalid. Is it ok for mainline? Or do we want a different error
> message? A somehow tighter check?

The error message needs to say something about typedef being the 
problem.  Maybe follow the pattern of the previous error, and say

         error ("declaration of %qD as %<typedef%>", dname);

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] PR 29003
  2011-06-09 14:19 ` Jason Merrill
@ 2011-06-09 14:37   ` Paolo Carlini
  2011-06-09 14:50     ` Jason Merrill
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2011-06-09 14:37 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

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

On 06/09/2011 04:06 PM, Jason Merrill wrote:
> On 06/09/2011 06:07 AM, Paolo Carlini wrote:
>> I tested on x86_64-linux the below patchlet for a long standing
>> accepts-invalid. Is it ok for mainline? Or do we want a different error
>> message? A somehow tighter check?
>
> The error message needs to say something about typedef being the 
> problem.  Maybe follow the pattern of the previous error, and say
>
>         error ("declaration of %qD as %<typedef%>", dname);
Right. Updated and retested. Is this variant Ok?

Thanks,
Paolo.

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

[-- Attachment #2: patch_29003_2 --]
[-- Type: text/plain, Size: 919 bytes --]

Index: testsuite/g++.dg/parse/error38.C
===================================================================
--- testsuite/g++.dg/parse/error38.C	(revision 0)
+++ testsuite/g++.dg/parse/error38.C	(revision 0)
@@ -0,0 +1,3 @@
+// PR c++/29003
+
+typedef int operator !(); // { dg-error "declaration" }
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 174838)
+++ cp/decl.c	(working copy)
@@ -8441,6 +8441,13 @@ grokdeclarator (const cp_declarator *declarator,
       return error_mark_node;
     }
 
+  if (dname && IDENTIFIER_OPNAME_P (dname)
+      && declspecs->specs[(int)ds_typedef])
+    {
+      error ("declaration of %qD as %<typedef%>", dname);
+      return error_mark_node;
+    }
+
   /* Anything declared one level down from the top level
      must be one of the parameters of a function
      (because the body is at least two levels down).  */

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [C++ Patch] PR 29003
  2011-06-09 14:37   ` Paolo Carlini
@ 2011-06-09 14:50     ` Jason Merrill
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Merrill @ 2011-06-09 14:50 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-09 14:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-09 11:44 [C++ Patch] PR 29003 Paolo Carlini
2011-06-09 14:19 ` Jason Merrill
2011-06-09 14:37   ` Paolo Carlini
2011-06-09 14:50     ` Jason Merrill

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).