]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/4286 (Internal error: Segmentation fault)
authorJason Merrill <jason@redhat.com>
Fri, 1 Feb 2002 15:50:01 +0000 (10:50 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 1 Feb 2002 15:50:01 +0000 (10:50 -0500)
        * decl2.c (finish_static_data_member_decl): Complain about a local
        class with a static data member.

        PR c++/4286
        * search.c (lookup_field_1): Don't xref a static data member
        just because we looked it up.

From-SVN: r49395

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/search.c
gcc/testsuite/g++.dg/template/local1.C [new file with mode: 0644]

index 91d3dc69bd305e8284ff9cfb95815f3ca8193c75..a3aa99e005181ed6eeabd311e65c921b907d2ddc 100644 (file)
@@ -1,3 +1,19 @@
+2002-02-01  Jason Merrill  <jason@redhat.com>
+
+       PR c++/4872
+       * decl.c (finish_function): Warn about a non-void function with 
+       no return statement.
+
+       * error.c (dump_scope): Don't add TFF_DECL_SPECIFIERS.
+       (dump_function_decl): Always dump parms.
+
+       * decl2.c (finish_static_data_member_decl): Complain about a local
+       class with a static data member.
+
+       PR c++/4286
+       * search.c (lookup_field_1): Don't xref a static data member
+       just because we looked it up.
+
 2002-01-31  Jason Merrill  <jason@redhat.com>
 
        * Make-lang.in (parse.c): Handle .output file.
index 70fcf45278671735036f15e616678ae896b6290a..9b1c355f7c8703fc84485978af45bd3b1c91a4a4 100644 (file)
@@ -1420,6 +1420,10 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags)
       VARRAY_PUSH_TREE (pending_statics, decl);
     }
 
+  if (LOCAL_CLASS_P (current_class_type))
+    pedwarn ("local class `%#T' shall not have static data member `%#D'",
+            current_class_type, decl);
+
   /* Static consts need not be initialized in the class definition.  */
   if (init != NULL_TREE && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
     {
index 22d53323468d5432b1657d47f065fde2b6a2d8f7..10ebc739f077683c3cbeb23d8aa1507796fdf65d 100644 (file)
@@ -523,13 +523,7 @@ lookup_field_1 (type, name)
           from TYPE_FIELDS anyhow; see handle_using_decl.  */
        ;
       else if (DECL_NAME (field) == name)
-       {
-         if (TREE_CODE(field) == VAR_DECL 
-             && (TREE_STATIC (field) || DECL_EXTERNAL (field)))
-           GNU_xref_ref(current_function_decl,
-                        IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (field)));
-         return field;
-       }
+       return field;
       field = TREE_CHAIN (field);
     }
   /* Not found.  */
diff --git a/gcc/testsuite/g++.dg/template/local1.C b/gcc/testsuite/g++.dg/template/local1.C
new file mode 100644 (file)
index 0000000..85b0056
--- /dev/null
@@ -0,0 +1,25 @@
+// PR c++/4286: We were crashing when trying to set up the class bindings in
+// g(), because xref wanted the mangled name, which breaks inside a template.
+
+// Of course, the offending code is actually ill-formed anyway, so check
+// for the error.
+
+struct A
+{
+  template<class T> void f();
+};
+
+template<class T> void A::f()
+{
+  struct B
+  {
+    void g() {}
+    static int x;              // { dg-error "static" "" }
+  };
+}
+
+int main ()
+{
+  A a;
+  a.f<int> ();
+}
This page took 0.080654 seconds and 5 git commands to generate.