From: Jason Merrill Date: Tue, 26 May 1998 11:43:52 +0000 (-0400) Subject: decl.c (pushdecl): Don't copy the type_decl. X-Git-Tag: prereleases/egcs-1.1-prerelease~1078 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7fb4a8f7e65f7e2d4f84ba958fd544080d1a69b1;p=thirdparty%2Fgcc.git decl.c (pushdecl): Don't copy the type_decl. * 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b3c572c0c2d4..21e0c6eaa32c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,9 +1,22 @@ +1998-05-26 Jason Merrill + + * decl.c (pushdecl): Don't copy the type_decl. + +1998-05-26 Martin v. Löwis + + * 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 * 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 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index ad4ff0065dab..e7019a86e438 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4668,6 +4668,7 @@ pushclass (type, modify) tree type; int modify; { + type = TYPE_MAIN_VARIANT (type); push_memoized_context (type, modify); current_class_depth++; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 804e2251b8db..822874ecb458 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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 - void f() - { - typedef S 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(); - } - - 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 diff --git a/gcc/cp/parse.c b/gcc/cp/parse.c index 69a212e5d1c8..2ee723056d9a 100644 --- a/gcc/cp/parse.c +++ b/gcc/cp/parse.c @@ -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;} diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index 8f04278b8927..664256e51902 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -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