OSDN Git Service

PR c++/5333
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 Feb 2003 07:43:23 +0000 (07:43 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 24 Feb 2003 07:43:23 +0000 (07:43 +0000)
* cp-tree.h (CLASSTYPE_PRIMARY_TEMPLATE): New macro.
* parser.c (cp_parser_diagnose_invalid_type_name): Use it.
* pt.c (instantiate_class_template): Don't try to instantiate
dependent types.
(resolve_typename_type): Use CLASSTYPE_PRIMARY_TEMPLATE.

PR c++/5333
* g++.dg/parse/fused-params1.C: Adjust error messages.
* g++.dg/template/nested3.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/fused-params1.C
gcc/testsuite/g++.dg/template/nested3.C [new file with mode: 0644]

index 00be1dd..20e1f22 100644 (file)
@@ -1,3 +1,12 @@
+2003-02-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/5333
+       * cp-tree.h (CLASSTYPE_PRIMARY_TEMPLATE): New macro.
+       * parser.c (cp_parser_diagnose_invalid_type_name): Use it.
+       * pt.c (instantiate_class_template): Don't try to instantiate
+       dependent types.
+       (resolve_typename_type): Use CLASSTYPE_PRIMARY_TEMPLATE.
+       
 2003-02-21  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/9749
index e463fb4..919e529 100644 (file)
@@ -2316,6 +2316,12 @@ struct lang_decl GTY(())
 #define ENUM_TI_ARGS(NODE)                     \
   TI_ARGS (ENUM_TEMPLATE_INFO (NODE))
 
+/* For a template instantiation TYPE, returns the TYPE corresponding
+   to the primary template.  */
+#define CLASSTYPE_PRIMARY_TEMPLATE_TYPE(TYPE)                          \
+  TREE_TYPE (DECL_TEMPLATE_RESULT (DECL_PRIMARY_TEMPLATE               \
+                                  (CLASSTYPE_TI_TEMPLATE ((TYPE)))))
+
 /* Like DECL_TI_TEMPLATE, but for an ENUMERAL_, RECORD_, or UNION_TYPE.  */
 #define TYPE_TI_TEMPLATE(NODE)                 \
   (TI_TEMPLATE (TYPE_TEMPLATE_INFO (NODE)))
index 79ec8be..0688cdc 100644 (file)
@@ -1954,10 +1954,7 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser)
                     template (which will have an empty TYPE_FIELDs),
                     to the main version.  */
                  if (CLASSTYPE_USE_TEMPLATE (base_type))
-                   base_type = (TREE_TYPE
-                                (DECL_TEMPLATE_RESULT 
-                                 (DECL_PRIMARY_TEMPLATE
-                                  (CLASSTYPE_TI_TEMPLATE (base_type)))));
+                   base_type = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (base_type);
                  for (field = TYPE_FIELDS (base_type);
                       field;
                       field = TREE_CHAIN (field))
@@ -4526,6 +4523,7 @@ cp_parser_unary_operator (cp_token* token)
 
 /* Parse a new-expression.
 
+   new-expression:
      :: [opt] new new-placement [opt] new-type-id new-initializer [opt]
      :: [opt] new new-placement [opt] ( type-id ) new-initializer [opt]
 
index add427d..36ae04d 100644 (file)
@@ -5151,7 +5151,9 @@ instantiate_class_template (type)
   if (type == error_mark_node)
     return error_mark_node;
 
-  if (TYPE_BEING_DEFINED (type) || COMPLETE_TYPE_P (type))
+  if (TYPE_BEING_DEFINED (type) 
+      || COMPLETE_TYPE_P (type)
+      || dependent_type_p (type))
     return type;
 
   /* Figure out which template is being instantiated.  */
@@ -11526,6 +11528,10 @@ resolve_typename_type (tree type, bool only_current_p)
      to look inside it.  */
   if (only_current_p && !currently_open_class (scope))
     return error_mark_node;
+  /* If SCOPE is a partial instantiation, it will not have a valid
+     TYPE_FIELDS list, so use the original template.  */
+  if (CLASSTYPE_USE_TEMPLATE (scope))
+    scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope);
   /* Enter the SCOPE so that name lookup will be resolved as if we
      were in the class definition.  In particular, SCOPE will no
      longer be considered a dependent type.  */
index 73c1e5e..3dad6fd 100644 (file)
@@ -1,3 +1,9 @@
+2003-02-23  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/5333
+       * g++.dg/parse/fused-params1.C: Adjust error messages.
+       * g++.dg/template/nested3.C: New test.
+       
 2003-02-24  Alan Modra  <amodra@bigpond.net.au>
 
        * g++.dg/abi/param1.C: New test.
index 2e9378d..adb47a0 100644 (file)
@@ -3,9 +3,9 @@
 // { dg-do compile }
 
 template <int N,typename T> struct A
-{
+{ //  { dg-error "" } 
     typedef T X;
-    template <int M> void foo (const A<M,X>&); // { dg-error "candidate" }
+    template <int M> void foo (const A<M,X>&);
 };
 
 template <int N,int M,typename T>
diff --git a/gcc/testsuite/g++.dg/template/nested3.C b/gcc/testsuite/g++.dg/template/nested3.C
new file mode 100644 (file)
index 0000000..1c45d64
--- /dev/null
@@ -0,0 +1,28 @@
+template <class T1, class T2>
+class A {
+  template <class S>
+  class SubA {
+    int _k;
+  };
+  T1 _t1;
+  T2 _t2;
+};
+
+template <class U>
+class B {
+  class SubB1 {
+    B _i;
+  };
+
+  class SubB2 {
+    int _j;
+  };
+  A<U,SubB1>::SubA<SubB2> _a; // { dg-error "" }
+};
+
+
+int main() {
+  B<char> objB;
+
+  return 0;
+}