OSDN Git Service

PR c++/18652
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Nov 2004 14:17:33 +0000 (14:17 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Nov 2004 14:17:33 +0000 (14:17 +0000)
* name-lookup.c (pushtag): Change return type to tree.
* cp-tree.h (pushtag): Adjust declaration.
* decl.c (xref_tag, start_enum): Use return value of pushtag.
* pt.c (push_template_decl_real): Return immediately if
pushdecl_namespace_level returns error_mark_node.

* g++.dg/lookup/crash6.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/name-lookup.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/crash6.C [new file with mode: 0644]

index e99f280..e2f7dc4 100644 (file)
@@ -1,3 +1,12 @@
+2004-11-29  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/18652
+       * name-lookup.c (pushtag): Change return type to tree.
+       * cp-tree.h (pushtag): Adjust declaration.
+       * decl.c (xref_tag, start_enum): Use return value of pushtag.
+       * pt.c (push_template_decl_real): Return immediately if
+       pushdecl_namespace_level returns error_mark_node.
+
 2004-11-27  Kazu Hirata  <kazu@cs.umass.edu>
 
        * pt.c: Fix a comment typo.
index eb15258..1dfd52d 100644 (file)
@@ -3707,7 +3707,7 @@ extern void delete_block                  (tree);
 extern void add_block_current_level            (tree);
 extern void push_switch                                (tree);
 extern void pop_switch                         (void);
-extern void pushtag                            (tree, tree, int);
+extern tree pushtag                            (tree, tree, int);
 extern tree make_anon_name                     (void);
 extern int decls_match                         (tree, tree);
 extern tree duplicate_decls                    (tree, tree);
index 93c0417..7779080 100644 (file)
@@ -9284,7 +9284,7 @@ xref_tag (enum tag_types tag_code, tree name,
          t = make_aggr_type (code);
          TYPE_CONTEXT (t) = context;
          /* pushtag only cares whether SCOPE is zero or not.  */
-         pushtag (name, t, scope != ts_current);
+         t = pushtag (name, t, scope != ts_current);
        }
     }
   else
@@ -9539,7 +9539,7 @@ start_enum (tree name)
        name = make_anon_name ();
 
       enumtype = make_node (ENUMERAL_TYPE);
-      pushtag (name, enumtype, 0);
+      enumtype = pushtag (name, enumtype, 0);
     }
 
   return enumtype;
index ddbd78f..ee0d1a4 100644 (file)
@@ -4566,9 +4566,10 @@ maybe_process_template_type_declaration (tree type, int globalize,
 /* Push a tag name NAME for struct/class/union/enum type TYPE.
    Normally put it into the inner-most non-sk_cleanup scope,
    but if GLOBALIZE is true, put it in the inner-most non-class scope.
-   The latter is needed for implicit declarations.  */
+   The latter is needed for implicit declarations.
+   Returns TYPE upon success and ERROR_MARK_NODE otherwise.  */
 
-void
+tree
 pushtag (tree name, tree type, int globalize)
 {
   struct cp_binding_level *b;
@@ -4633,6 +4634,8 @@ pushtag (tree name, tree type, int globalize)
 
          d = maybe_process_template_type_declaration (type,
                                                       globalize, b);
+         if (d == error_mark_node)
+           return error_mark_node;
 
          if (b->kind == sk_class)
            {
@@ -4695,7 +4698,7 @@ pushtag (tree name, tree type, int globalize)
       tree d = build_decl (TYPE_DECL, NULL_TREE, type);
       TYPE_STUB_DECL (type) = pushdecl_with_scope (d, b);
     }
-  timevar_pop (TV_NAME_LOOKUP);
+  POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, type);
 }
 \f
 /* Subroutines for reverting temporarily to top-level for instantiation
index f8ba33d..fca3f3d 100644 (file)
@@ -3145,7 +3145,11 @@ push_template_decl_real (tree decl, int is_friend)
      parameters of the class.  */
   if (new_template_p && !ctx 
       && !(is_friend && template_class_depth (current_class_type) > 0))
-    tmpl = pushdecl_namespace_level (tmpl);
+    {
+      tmpl = pushdecl_namespace_level (tmpl);
+      if (tmpl == error_mark_node)
+       return error_mark_node;
+    }
 
   if (primary)
     {
index fa959a4..289d124 100644 (file)
@@ -1,3 +1,8 @@
+2004-11-29  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/18652
+       * g++.dg/lookup/crash6.C: New test.
+
 2004-11-29  Hans-Peter Nilsson  <hp@bitrange.com>
 
        PR middle-end/18164
diff --git a/gcc/testsuite/g++.dg/lookup/crash6.C b/gcc/testsuite/g++.dg/lookup/crash6.C
new file mode 100644 (file)
index 0000000..0e49324
--- /dev/null
@@ -0,0 +1,8 @@
+// { dg-do compile }
+
+// Origin: Volker Reichelt <reichelt@gcc.gnu.org>
+
+// PR c++/18652: ICE redeclaring variable as template.
+
+int A;                 // { dg-error "previous declaration" }
+template<int> struct A; // { dg-error "different kind of symbol" }