Patchwork [C++] PR 29003

login
register
mail settings
Submitter Paolo Carlini
Date June 9, 2011, 2:19 p.m.
Message ID <4DF0D668.4060107@oracle.com>
Download mbox | patch
Permalink /patch/99750/
State New
Headers show

Comments

Jason Merrill - June 9, 2011, 2:19 p.m.
OK.

Jason
Paolo Carlini - June 9, 2011, 2:19 p.m.
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.

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

Patch

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