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

From-SVN: r58054

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

index cc84a035c0a606f4ce2703c02f090a2372f456d7..dddcaacfb3e8f89cfb6c9c137fb86ed7f4edee84 100644 (file)
@@ -1,3 +1,9 @@
+2002-10-10  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-09  Zack Weinberg  <zack@codesourcery.com>
 
        PR c/7353
index 26484d72ef17661bcd20dc20f8018f88196238e5..6f11bd9de1ad24253513716f8323b4db4301145d 100644 (file)
@@ -10060,6 +10060,16 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
            next = 0;
            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' as type-specifier", 
+                  decl);
+           return error_mark_node;
+           break;
+
          default:
            internal_error ("`%D' as declarator", decl);
          }
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 "" "" }
+}