gxx.gperf (RETURN): Rename to RETURN_KEYWORD to avoid clashes with the RTL code RETURN.
authorMark Mitchell <mark@codesourcery.com>
Thu, 22 Apr 1999 17:37:02 +0000 (17:37 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 22 Apr 1999 17:37:02 +0000 (17:37 +0000)
* gxx.gperf (RETURN): Rename to RETURN_KEYWORD to avoid clashes
with the RTL code RETURN.
* hash.h: Regenerated.
* lex.c (reinit_parse_for_block): Use RETURN_KEYWORD.
* parse.y: Replace RETURN with RETURN_KEYWORD throughout.
* parse.c: Regenerated.
* pt.c: Include varray.h.  Include rtl.h since varray.h requires
it.
(inline_parm_levels): New variable.
(inline_parm_levels_used): Likewise.
(maybe_begin_member_template_processing): Update them.
(maybe_end_member_template_processing): Use them, rather than
guessing how many levels to pop.

From-SVN: r26587

gcc/cp/ChangeLog
gcc/cp/gxx.gperf
gcc/cp/hash.h
gcc/cp/lex.c
gcc/cp/parse.c
gcc/cp/parse.y
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.pt/crash39.C [new file with mode: 0644]

index fc813fe449c97f5780e493cc88c62f8859bc5432..d8ca82308afdd1994e5ee3a4a3f07c8130409e01 100644 (file)
@@ -1,5 +1,19 @@
 1999-04-22  Mark Mitchell  <mark@codesourcery.com>
 
+       * gxx.gperf (RETURN): Rename to RETURN_KEYWORD to avoid clashes
+       with the RTL code RETURN.
+       * hash.h: Regenerated.
+       * lex.c (reinit_parse_for_block): Use RETURN_KEYWORD.
+       * parse.y: Replace RETURN with RETURN_KEYWORD throughout.
+       * parse.c: Regenerated.
+       * pt.c: Include varray.h.  Include rtl.h since varray.h requires
+       it.
+       (inline_parm_levels): New variable.
+       (inline_parm_levels_used): Likewise.
+       (maybe_begin_member_template_processing): Update them.
+       (maybe_end_member_template_processing): Use them, rather than
+       guessing how many levels to pop.
+       
        * decl.c (make_typename_type): Tighten error-checking.
 
 1999-04-20  Mark Mitchell  <mark@codesourcery.com>
index 42762e6099854f19eff25d7d034c2c8d3d6c7936..1e621c4a22d60ce060d61bbd9198083fddaf712d 100644 (file)
@@ -81,7 +81,7 @@ protected, VISSPEC, RID_PROTECTED,
 public, VISSPEC, RID_PUBLIC,
 register, SCSPEC, RID_REGISTER,
 reinterpret_cast, REINTERPRET_CAST, NORID,
-return, RETURN, NORID,
+return, RETURN_KEYWORD, NORID,
 short, TYPESPEC, RID_SHORT,
 signature, AGGR, RID_SIGNATURE /* Extension */,
 signed, TYPESPEC, RID_SIGNED,
index 4cc867946b12501eb5a898e7d56d245716bad1c3..3c6199630c1eebd8b4da13dd276a370d813419e2 100644 (file)
@@ -1,5 +1,5 @@
 /* C code produced by gperf version 2.7.1 (19981006 egcs) */
-/* Command-line: gperf -L C -F , 0, 0 -p -j1 -g -o -t -N is_reserved_word -k1,4,7,$ ./gxx.gperf  */
+/* Command-line: gperf -L C -F , 0, 0 -p -j1 -g -o -t -N is_reserved_word -k1,4,7,$ ../../../gcc/cp/gxx.gperf  */
 /* Command-line: gperf -L KR-C -F ', 0, 0' -p -j1 -g -o -t -N is_reserved_word -k1,4,$,7 gplus.gperf  */
 struct resword { const char *name; short token; enum rid rid;};
 
@@ -191,7 +191,7 @@ is_reserved_word (str, len)
       {"reinterpret_cast", REINTERPRET_CAST, NORID,},
       {"mutable", SCSPEC, RID_MUTABLE,},
       {"__alignof", ALIGNOF, NORID},
-      {"return", RETURN, NORID,},
+      {"return", RETURN_KEYWORD, NORID,},
       {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0}, {"", 0, 0},
       {"", 0, 0},
       {"float", TYPESPEC, RID_FLOAT,},
index de7873db76ad9a635f8004a1cff3021e41757480..a9bb9cf403066323c8b1b9f1ed8f850d94cfb5f6 100644 (file)
@@ -1496,7 +1496,7 @@ reinit_parse_for_block (pyychar, obstackp)
       look_for_lbrac = 1;
       blev = 0;
     }
-  else if (pyychar == RETURN)
+  else if (pyychar == RETURN_KEYWORD)
     {
       obstack_grow (obstackp, "return", 6);
       look_for_lbrac = 1;
index 61bf895a82491b3636412276b2b3f067db618209..fff2dd4fe09b5ea50b5638c729897d5931087e3c 100644 (file)
@@ -27,7 +27,7 @@
 #define        DEFAULT 277
 #define        BREAK   278
 #define        CONTINUE        279
-#define        RETURN  280
+#define        RETURN_KEYWORD  280
 #define        GOTO    281
 #define        ASM_KEYWORD     282
 #define        TYPEOF  283
@@ -742,35 +742,36 @@ static const short yyrline[] = { 0,
 static const char * const yytname[] = {   "$","error","$undefined.","IDENTIFIER",
 "TYPENAME","SELFNAME","PFUNCNAME","SCSPEC","TYPESPEC","CV_QUALIFIER","CONSTANT",
 "STRING","ELLIPSIS","SIZEOF","ENUM","IF","ELSE","WHILE","DO","FOR","SWITCH",
-"CASE","DEFAULT","BREAK","CONTINUE","RETURN","GOTO","ASM_KEYWORD","TYPEOF","ALIGNOF",
-"SIGOF","ATTRIBUTE","EXTENSION","LABEL","REALPART","IMAGPART","AGGR","VISSPEC",
-"DELETE","NEW","THIS","OPERATOR","CXX_TRUE","CXX_FALSE","NAMESPACE","TYPENAME_KEYWORD",
-"USING","LEFT_RIGHT","TEMPLATE","TYPEID","DYNAMIC_CAST","STATIC_CAST","REINTERPRET_CAST",
-"CONST_CAST","SCOPE","EMPTY","PTYPENAME","NSNAME","'{'","','","';'","THROW",
-"':'","ASSIGN","'='","'?'","OROR","ANDAND","'|'","'^'","'&'","MIN_MAX","EQCOMPARE",
-"ARITHCOMPARE","'<'","'>'","LSHIFT","RSHIFT","'+'","'-'","'*'","'/'","'%'","POINTSAT_STAR",
-"DOT_STAR","UNARY","PLUSPLUS","MINUSMINUS","'~'","HYPERUNARY","PAREN_STAR_PAREN",
-"POINTSAT","'.'","'('","'['","TRY","CATCH","PRE_PARSED_FUNCTION_DECL","EXTERN_LANG_STRING",
-"ALL","PRE_PARSED_CLASS_DECL","DEFARG","DEFARG_MARKER","TYPENAME_DEFN","IDENTIFIER_DEFN",
-"PTYPENAME_DEFN","END_OF_LINE","END_OF_SAVED_INPUT","')'","'}'","'!'","']'",
-"program","extdefs","@1","extdefs_opt",".hush_warning",".warning_ok","extension",
-"asm_keyword","lang_extdef","@2","extdef","@3","@4","namespace_alias","@5","using_decl",
-"namespace_using_decl","using_directive","@6","namespace_qualifier","any_id",
-"extern_lang_string","template_header","@7","template_parm_list","maybe_identifier",
-"template_type_parm","template_template_parm","template_parm","template_def",
-"template_extdef","template_datadef","datadef","ctor_initializer_opt","maybe_return_init",
-"eat_saved_input","fndef","constructor_declarator","@8","@9","@10","@11","fn.def1",
-"component_constructor_declarator","fn.def2","return_id","return_init","base_init",
-".set_base_init","member_init_list","member_init","identifier","notype_identifier",
-"identifier_defn","explicit_instantiation","@12","@13","@14","@15","@16","@17",
-"@18","@19","begin_explicit_instantiation","end_explicit_instantiation","template_type",
-"apparent_template_type","self_template_type",".finish_template_type","template_close_bracket",
-"template_arg_list_opt","template_arg_list","template_arg","unop","expr","paren_expr_or_null",
-"paren_cond_or_null","xcond","condition","@20","compstmtend","already_scoped_stmt",
-"@21","nontrivial_exprlist","nonnull_exprlist","unary_expr",".finish_new_placement",
-".begin_new_placement","new_placement","new_initializer","regcast_or_absdcl",
-"cast_expr","expr_no_commas","notype_unqualified_id","do_id","template_id","object_template_id",
-"unqualified_id","expr_or_declarator_intern","expr_or_declarator","notype_template_declarator",
+"CASE","DEFAULT","BREAK","CONTINUE","RETURN_KEYWORD","GOTO","ASM_KEYWORD","TYPEOF",
+"ALIGNOF","SIGOF","ATTRIBUTE","EXTENSION","LABEL","REALPART","IMAGPART","AGGR",
+"VISSPEC","DELETE","NEW","THIS","OPERATOR","CXX_TRUE","CXX_FALSE","NAMESPACE",
+"TYPENAME_KEYWORD","USING","LEFT_RIGHT","TEMPLATE","TYPEID","DYNAMIC_CAST","STATIC_CAST",
+"REINTERPRET_CAST","CONST_CAST","SCOPE","EMPTY","PTYPENAME","NSNAME","'{'","','",
+"';'","THROW","':'","ASSIGN","'='","'?'","OROR","ANDAND","'|'","'^'","'&'","MIN_MAX",
+"EQCOMPARE","ARITHCOMPARE","'<'","'>'","LSHIFT","RSHIFT","'+'","'-'","'*'","'/'",
+"'%'","POINTSAT_STAR","DOT_STAR","UNARY","PLUSPLUS","MINUSMINUS","'~'","HYPERUNARY",
+"PAREN_STAR_PAREN","POINTSAT","'.'","'('","'['","TRY","CATCH","PRE_PARSED_FUNCTION_DECL",
+"EXTERN_LANG_STRING","ALL","PRE_PARSED_CLASS_DECL","DEFARG","DEFARG_MARKER",
+"TYPENAME_DEFN","IDENTIFIER_DEFN","PTYPENAME_DEFN","END_OF_LINE","END_OF_SAVED_INPUT",
+"')'","'}'","'!'","']'","program","extdefs","@1","extdefs_opt",".hush_warning",
+".warning_ok","extension","asm_keyword","lang_extdef","@2","extdef","@3","@4",
+"namespace_alias","@5","using_decl","namespace_using_decl","using_directive",
+"@6","namespace_qualifier","any_id","extern_lang_string","template_header","@7",
+"template_parm_list","maybe_identifier","template_type_parm","template_template_parm",
+"template_parm","template_def","template_extdef","template_datadef","datadef",
+"ctor_initializer_opt","maybe_return_init","eat_saved_input","fndef","constructor_declarator",
+"@8","@9","@10","@11","fn.def1","component_constructor_declarator","fn.def2",
+"return_id","return_init","base_init",".set_base_init","member_init_list","member_init",
+"identifier","notype_identifier","identifier_defn","explicit_instantiation",
+"@12","@13","@14","@15","@16","@17","@18","@19","begin_explicit_instantiation",
+"end_explicit_instantiation","template_type","apparent_template_type","self_template_type",
+".finish_template_type","template_close_bracket","template_arg_list_opt","template_arg_list",
+"template_arg","unop","expr","paren_expr_or_null","paren_cond_or_null","xcond",
+"condition","@20","compstmtend","already_scoped_stmt","@21","nontrivial_exprlist",
+"nonnull_exprlist","unary_expr",".finish_new_placement",".begin_new_placement",
+"new_placement","new_initializer","regcast_or_absdcl","cast_expr","expr_no_commas",
+"notype_unqualified_id","do_id","template_id","object_template_id","unqualified_id",
+"expr_or_declarator_intern","expr_or_declarator","notype_template_declarator",
 "direct_notype_declarator","primary","@22","new","delete","boolean.literal",
 "string","nodecls","object","decl","declarator","fcast_or_absdcl","type_id",
 "typed_declspecs","typed_declspecs1","reserved_declspecs","declmods","typed_typespecs",
index d9b232f04cb6d70fd47c9e4cd78a1c32e5c4ca25..89b35175ca5fe3e9d4a4e0848fcd501c535a910d 100644 (file)
@@ -131,7 +131,7 @@ empty_parms ()
 /* the reserved words */
 /* SCO include files test "ASM", so use something else.  */
 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
-%token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
+%token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
 %token SIGOF
 %token ATTRIBUTE EXTENSION LABEL
 %token REALPART IMAGPART
@@ -756,7 +756,7 @@ fn.def2:
        ;
 
 return_id:
-         RETURN IDENTIFIER
+         RETURN_KEYWORD IDENTIFIER
                {
                  if (! current_function_parms_stored)
                    store_parm_decls ();
@@ -2475,7 +2475,7 @@ component_decl:
                { $$ = finish_method ($$); }
        | fn.def2 TRY /* base_init compstmt */
                { $$ = finish_method ($$); }
-       | fn.def2 RETURN /* base_init compstmt */
+       | fn.def2 RETURN_KEYWORD /* base_init compstmt */
                { $$ = finish_method ($$); }
        | fn.def2 '{' /* nodecls compstmt */
                { $$ = finish_method ($$); }
@@ -3335,9 +3335,9 @@ simple_stmt:
                 { finish_break_stmt (); }
        | CONTINUE ';'
                 { finish_continue_stmt (); }
-       | RETURN ';'
+       | RETURN_KEYWORD ';'
                 { finish_return_stmt (NULL_TREE); }
-       | RETURN expr ';'
+       | RETURN_KEYWORD expr ';'
                 { finish_return_stmt ($2); }
        | asm_keyword maybe_cv_qualifier '(' string ')' ';'
                { 
index 5a3624705722c663af23983de2b54992e78f7267..aeb827f3e9c45efa20ec98efd95ed764e127ee91 100644 (file)
@@ -39,6 +39,8 @@ Boston, MA 02111-1307, USA.  */
 #include "defaults.h"
 #include "except.h"
 #include "toplev.h"
+#include "rtl.h"
+#include "varray.h"
 
 /* The type of functions taking a tree, and some additional data, and
    returning an int.  */
@@ -67,6 +69,8 @@ int processing_template_parmlist;
 static int template_header_count;
 
 static tree saved_trees;
+static varray_type inline_parm_levels;
+static size_t inline_parm_levels_used;
 
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
@@ -399,22 +403,30 @@ maybe_begin_member_template_processing (decl)
      tree decl;
 {
   tree parms;
-  int levels;
+  int levels = 0;
 
-  if (inline_needs_template_parms (decl))
-    return;
-
-  parms = DECL_TEMPLATE_PARMS (most_general_template (decl));
+  if (inline_needs_template_parms (decl))
+    {
+      parms = DECL_TEMPLATE_PARMS (most_general_template (decl));
+      levels = TMPL_PARMS_DEPTH (parms) - processing_template_decl;
 
-  levels = TMPL_PARMS_DEPTH (parms) - processing_template_decl;
+      if (DECL_TEMPLATE_SPECIALIZATION (decl))
+       {
+         --levels;
+         parms = TREE_CHAIN (parms);
+       }
 
-  if (DECL_TEMPLATE_SPECIALIZATION (decl))
-    {
-      --levels;
-      parms = TREE_CHAIN (parms);
+      push_inline_template_parms_recursive (parms, levels);
     }
 
-  push_inline_template_parms_recursive (parms, levels);
+  /* Remember how many levels of template parameters we pushed so that
+     we can pop them later.  */
+  if (!inline_parm_levels)
+    VARRAY_INT_INIT (inline_parm_levels, 4, "inline_parm_levels");
+  if (inline_parm_levels_used == inline_parm_levels->num_elements)
+    VARRAY_GROW (inline_parm_levels, 2 * inline_parm_levels_used);
+  VARRAY_INT (inline_parm_levels, inline_parm_levels_used) = levels;
+  ++inline_parm_levels_used;
 }
 
 /* Undo the effects of begin_member_template_processing. */
@@ -422,11 +434,15 @@ maybe_begin_member_template_processing (decl)
 void 
 maybe_end_member_template_processing ()
 {
-  if (! processing_template_decl)
+  int i;
+
+  if (!inline_parm_levels_used)
     return;
 
-  while (current_template_parms
-        && TEMPLATE_PARMS_FOR_INLINE (current_template_parms))
+  --inline_parm_levels_used;
+  for (i = 0; 
+       i < VARRAY_INT (inline_parm_levels, inline_parm_levels_used);
+       ++i) 
     {
       --processing_template_decl;
       current_template_parms = TREE_CHAIN (current_template_parms);
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash39.C b/gcc/testsuite/g++.old-deja/g++.pt/crash39.C
new file mode 100644 (file)
index 0000000..2c4bb5a
--- /dev/null
@@ -0,0 +1,19 @@
+// Build don't link:
+// Origin: Ian Nixon <ian@tharas.com>
+
+class Action {
+public:
+  virtual void action () = 0;
+};
+
+class Var {
+public:
+
+  template<class Base> void Add() {
+       struct tmp : public Action {
+         void action () {}
+       };
+       tmp *tp = new tmp; 
+  }
+
+};