PRs C++/6803, C++/7721 and C++/7803
authorGabriel Dos Reis <gdr@integrable-solutions.net>
Fri, 11 Oct 2002 18:25:10 +0000 (18:25 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Fri, 11 Oct 2002 18:25:10 +0000 (18:25 +0000)
        PRs C++/6803, C++/7721 and C++/7803
        * decl.c (grokdeclarator): Gracefully handle template-name as
        decl-specifier.

From-SVN: r58058

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

index 01f8551c10cefc2c586351fe29770f288b630884..200bc3937756ea17b7ffc484d1e0c1ccd289c4e1 100644 (file)
@@ -1,3 +1,9 @@
+2002-10-11  Gabriel Dos Reis  <gdr@integrable-solutions.net>
+
+       PRs C++/6803, C++/7721 and C++/7803
+       * decl.c (grokdeclarator): Gracefully handle template-name as
+       decl-specifier.
+
 2002-10-11  Jason Molenda  <jmolenda@apple.com>
 
        * init.c (build_field_list): Provide uses_unions_p with a default
index f4651dbefcd2be79ad868303b21e60bfcc538964..f8202b46e46c453871bad54dc99e6f783b0d9b40 100644 (file)
@@ -10249,6 +10249,15 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
          case BASELINK:
            next = &BASELINK_FUNCTIONS (decl);
            break;
+
+         case TEMPLATE_DECL:
+           /* Sometimes, we see a template-name used as part of a 
+              decl-specifier like in 
+                 std::allocator alloc;
+              Handle that gracefully.  */
+           error ("invalid use of template-name '%E' in a declarator", decl);
+           return error_mark_node;
+           break;
            
          default:
            my_friendly_assert (0, 20020917);
diff --git a/gcc/testsuite/g++.dg/parse/decl-specifier-1.C b/gcc/testsuite/g++.dg/parse/decl-specifier-1.C
new file mode 100644 (file)
index 0000000..e81fbab
--- /dev/null
@@ -0,0 +1,16 @@
+// Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
+// Origin: PRs 7721 and 7803
+// { dg-do compile }
+
+namespace N
+{
+    template<typename> 
+    struct X { };
+}
+
+N::X X;                           // { dg-error "" "" }
+
+int main()
+{
+    return sizeof(X);             // { dg-error "" "" }
+}