]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/29003 (operator name accepted in typedef)
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 9 Jun 2011 15:06:59 +0000 (15:06 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 9 Jun 2011 15:06:59 +0000 (15:06 +0000)
/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.

From-SVN: r174846

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/error38.C [new file with mode: 0644]

index 2ffefaf15bab4fcac6179695c4a64d345221670e..df665d1f57f7a0e800b455aa23f0ed0c89a26859 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-09  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/29003
+       * decl.c (grokdeclarator): Reject operator names in typedefs.
+
 2011-06-08  Jason Merrill  <jason@redhat.com>
 
        PR c++/49107
index d7da39081541b47702c6e12bf330b8ca807be50d..a7447c3d6fe70e9147fd7cd70883fd19a72ec2a6 100644 (file)
@@ -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).  */
index d2ebaf6ca6dfa8b79ecc46b3eb5d19b50e4c0c8d..6bece5724ff101ad8ad4113eb0e2f9878b7ab31a 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-09  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/29003
+       * g++.dg/parse/error38.C: New.
+
 2011-06-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/49308
diff --git a/gcc/testsuite/g++.dg/parse/error38.C b/gcc/testsuite/g++.dg/parse/error38.C
new file mode 100644 (file)
index 0000000..63162a8
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/29003
+
+typedef int operator !(); // { dg-error "declaration" }
This page took 0.101521 seconds and 5 git commands to generate.