OSDN Git Service

cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Feb 2001 10:49:44 +0000 (10:49 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Feb 2001 10:49:44 +0000 (10:49 +0000)
* pt.c (lookup_template_class): Make sure it's a primary
template or template_template_parm when called from the parser.
(instantiate_template_class): Add assertion.
testsuite:
* g++.old-deja/g++.pt/spec39.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39488 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.pt/spec39.C [new file with mode: 0644]

index 72bc2f0..29901cb 100644 (file)
@@ -1,3 +1,9 @@
+2001-02-06  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * pt.c (lookup_template_class): Make sure it's a primary
+       template or template_template_parm when called from the parser.
+       (instantiate_template_class): Add assertion.
+
 2001-02-05  Alexandre Oliva  <aoliva@redhat.com>
 
        * method.c (build_mangled_name) [old abi]: Protect flush_repeats()
index a17343d..e85ec79 100644 (file)
@@ -3893,7 +3893,12 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain)
       return error_mark_node;
     }
 
-  if (TREE_CODE (template) != TEMPLATE_DECL)
+  if (TREE_CODE (template) != TEMPLATE_DECL
+         /* If we're called from the parser, make sure it's a user visible
+            template.  */
+      || ((!arglist || TREE_CODE (arglist) == TREE_LIST)
+          && !DECL_TEMPLATE_PARM_P (template)
+          && !PRIMARY_TEMPLATE_P (template)))
     {
       if (complain)
         {
@@ -5109,6 +5114,7 @@ instantiate_class_template (type)
       tree newtag;
 
       newtag = tsubst (tag, args, /*complain=*/1, NULL_TREE);
+      my_friendly_assert (newtag != error_mark_node, 20010206);
       if (TREE_CODE (newtag) != ENUMERAL_TYPE)
        {
          if (TYPE_LANG_SPECIFIC (tag) && CLASSTYPE_IS_TEMPLATE (tag))
index 3ce1ec3..b7b998d 100644 (file)
@@ -1,3 +1,7 @@
+2001-02-06  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.old-deja/g++.pt/spec39.C: New test.
+
 2001-02-05  Jakub Jelinek  <jakub@redhat.com>
 
        * gcc.c-torture/compile/20010202-1.c: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec39.C b/gcc/testsuite/g++.old-deja/g++.pt/spec39.C
new file mode 100644 (file)
index 0000000..9cdf75c
--- /dev/null
@@ -0,0 +1,43 @@
+// Build don't link:
+// 
+// Copyright (C) 2000 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 19 Jan 2001 <nathan@codesourcery.com>
+
+// Bug 1656. We failed to make sure that a template-id was built
+// from a primary template.
+
+template <int dim> struct Outer
+{
+  struct Inner {};
+
+  void f()
+  {
+    Inner<dim> i;         // ERROR - non-template
+    Inner<> j;            // ERROR - non-template
+  }
+};
+struct O {};
+void foo ()
+{
+  Outer<1> x;
+  x.f ();
+  Outer<1>::Inner<2> z;   // ERROR - non-template
+  O<1> w;                 // ERROR - non-template
+}
+
+template <typename T, template <typename C> class TPL>
+struct X
+{
+  TPL<T> t;
+  T<int> s;     // ERROR - non-template
+};
+
+template <typename T> struct Y
+{
+};
+
+void bar ()
+{
+  X<int, Y> a;
+  X<int, O> b;  // ERROR - non-template
+}