re PR c++/46005 ([C++0x] Don't allow "auto" as the simple-type-specifier of a typedef)
authorJason Merrill <jason@redhat.com>
Wed, 25 May 2011 19:52:02 +0000 (15:52 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 25 May 2011 19:52:02 +0000 (15:52 -0400)
PR c++/46145
* decl.c (grokdeclarator): Complain about auto typedef.

From-SVN: r174228

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/auto9.C

index d78f18324edd025a42ce41feca0c1bb9480b8125..7493fd2f5127faa453d6f885e3ca80e1e8b041e3 100644 (file)
@@ -1,5 +1,8 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       PR c++/46145
+       * decl.c (grokdeclarator): Complain about auto typedef.
+
        PR c++/46245
        * decl.c (grokdeclarator): Complain later for auto parameter.
        * pt.c (splice_late_return_type): Handle use in a template
index 8000441d06f82c40f64fea9023d6bf4246a92404..2b6a7770e2db77e6bf6dc6d92e4d93c8131d3ecf 100644 (file)
@@ -9481,6 +9481,12 @@ grokdeclarator (const cp_declarator *declarator,
           memfn_quals = TYPE_UNQUALIFIED;
         }
 
+      if (type_uses_auto (type))
+       {
+         error ("typedef declared %<auto%>");
+         type = error_mark_node;
+       }
+
       if (decl_context == FIELD)
        decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
       else
index 3cc818adc80731406d6872328463ac95dfdebb2d..7e88ecc8b5ff00a69f94e7322a6fb89f769d20a2 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-25  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/auto9.C: Add typedef test.
+
        * g++.dg/cpp0x/auto23.C: New.
        * g++.dg/cpp0x/auto9.C: Adjust.
 
index 142ef904f2d7d74add48eb0b810e719b2eba2235..190bfa6e8f02bddc4a11c540fec565b8489457f3 100644 (file)
@@ -119,3 +119,6 @@ H<auto> h;                                  // { dg-error "invalid" }
 
 void qq (auto);                        // { dg-error "auto" }
 void qr (auto*);               // { dg-error "auto" }
+
+// PR c++/46145
+typedef auto autot;            // { dg-error "auto" }