decl.c (pushdecl): Don't copy the type_decl.
authorJason Merrill <jason@gcc.gnu.org>
Tue, 26 May 1998 11:43:52 +0000 (07:43 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 26 May 1998 11:43:52 +0000 (07:43 -0400)
* decl.c (pushdecl): Don't copy the type_decl.
* class.c (pushclass): Always store TYPE_MAIN_VARIANT in
current_class_type.
* decl.c (grokdeclarator): Put typedefs on the type's obstack.
* parse.y (complex_direct_notype_declarator): Use $1 to access
scope of notype_qualified_id.

From-SVN: r20061

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/decl.c
gcc/cp/parse.c
gcc/cp/parse.y

index b3c572c0c2d4b00caef0c2037688ef00d2c14cd6..21e0c6eaa32c30e4fdfdc3e529faeb04b2e02854 100644 (file)
@@ -1,9 +1,22 @@
+1998-05-26  Jason Merrill  <jason@yorick.cygnus.com>
+
+       * decl.c (pushdecl): Don't copy the type_decl.
+
+1998-05-26  Martin v. Löwis  <loewis@informatik.hu-berlin.de>
+
+       * class.c (pushclass): Always store TYPE_MAIN_VARIANT in
+       current_class_type.
+       * decl.c (grokdeclarator): Put typedefs on the type's obstack.
+
+       * parse.y (complex_direct_notype_declarator): Use $1 to access
+       scope of notype_qualified_id.
+
 1998-05-26  Dave Brolley  <brolley@cygnus.com>
 
        * lex.c (parse_options,yy_cur,yy_lim): Add for cpplib.
        (init_parse): Initialize cpplib interface.
 
-       * Makefile.in (CXX_OBJS): Make sure dependencies nenver end with an
+       * Makefile.in (CXX_OBJS): Make sure dependencies never end with an
        empty continuation.
 
 1998-05-26  Mark Mitchell  <mark@markmitchell.com>
index ad4ff0065dab0cff1a2e087a03d1726b21d6a028..e7019a86e4387d684a2eb0621f6971f601417e38 100644 (file)
@@ -4668,6 +4668,7 @@ pushclass (type, modify)
      tree type;
      int modify;
 {
+  type = TYPE_MAIN_VARIANT (type);
   push_memoized_context (type, modify);
 
   current_class_depth++;
index 804e2251b8dbdec3a83289822b91071e5054c1da..822874ecb458d4b093639733d100f3ad78f9368c 100644 (file)
@@ -3373,43 +3373,6 @@ pushdecl (x)
             {
              push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
 
-             if (!TREE_PERMANENT (x) 
-                 && TYPE_OBSTACK (type) != saveable_obstack)
-               {
-                 /* X should have been allocated on the saveable
-                    obstack.  Since the type was not, the type may
-                    outlive X, unless we make a copy of X.  Here are
-                    some examples:
-                    
-                    template <class T>
-                    void f()
-                    {
-                      typedef S<T> Type_t;
-                      Type_t::foo();
-                    }
-                    
-                    Here, we will create a SCOPE_REF with Type_t as
-                    its first argument, and save the SCOPE_REF for
-                    later, so that we can tsubst into it.  But, that
-                    means we need to save the TYPE_DECL for Type_t.
-                    
-                    But, we must save the TYPE_DECL even when not
-                    processing_template_decl.  For example,
-                    
-                    void f() 
-                    {
-                      typedef int I;
-                      g<I>();
-                    }
-                    
-                    may create a declaration of g with `I' as one of
-                    the arguments.  In the old days, we used to use
-                    the underlying types for things, but now we try
-                    to use the typedef names for readability.  */
-                 x = copy_node (x);
-                 copy_lang_decl (x);
-               }
-
              DECL_ORIGINAL_TYPE (x) = type;
               type = build_type_copy (type);
              TYPE_STUB_DECL (type) = TYPE_STUB_DECL (DECL_ORIGINAL_TYPE (x));
@@ -9624,7 +9587,13 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
       else if (current_lang_name == lang_name_java)
        decl = build_lang_decl (TYPE_DECL, declarator, type);
       else
-       decl = build_decl (TYPE_DECL, declarator, type);
+       {
+         /* Make sure this typedef lives as long as its type,
+            since it might be used as a template parameter. */
+         push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
+         decl = build_decl (TYPE_DECL, declarator, type);
+         pop_obstacks ();
+       }
 
       /* If the user declares "struct {...} foo" then `foo' will have
         an anonymous name.  Fill that name in now.  Nothing can
index 69a212e5d1c8738c29880315ab5c49c2b281176e..2ee723056d9a83be683324d3cfd0590a0b48dedf 100644 (file)
@@ -6596,10 +6596,10 @@ case 590:
     break;}
 case 591:
 #line 2743 "parse.y"
-{ if (OP0 (yyval.ttype) != current_class_type)
+{ if (OP0 (yyvsp[0].ttype) != current_class_type)
                    {
-                     push_nested_class (OP0 (yyval.ttype), 3);
-                     TREE_COMPLEXITY (yyval.ttype) = current_class_depth;
+                     push_nested_class (OP0 (yyvsp[0].ttype), 3);
+                     TREE_COMPLEXITY (yyvsp[0].ttype) = current_class_depth;
                    }
                ;
     break;}
index 8f04278b8927bb067539ca9a0f228bf1d99d4530..664256e519020f978fed1e82577d03aec02ef03c 100644 (file)
@@ -2740,10 +2740,10 @@ complex_direct_notype_declarator:
        | direct_notype_declarator '[' ']'
                { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
        | notype_qualified_id
-               { if (OP0 ($$) != current_class_type)
+               { if (OP0 ($1) != current_class_type)
                    {
-                     push_nested_class (OP0 ($$), 3);
-                     TREE_COMPLEXITY ($$) = current_class_depth;
+                     push_nested_class (OP0 ($1), 3);
+                     TREE_COMPLEXITY ($1) = current_class_depth;
                    }
                }
         | nested_name_specifier notype_template_declarator