diff options
author | Jason Merrill <jason@redhat.com> | 2002-02-01 10:50:01 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2002-02-01 10:50:01 -0500 |
commit | 65f36ac8689fcf7c2794b4693bd921fe6893dfe1 (patch) | |
tree | 8b39924f004b741d2dea0d7a5e5b7421fc1f6771 | |
parent | 5ee4950e46c20b9b14b2fca1997b63121b5158b1 (diff) | |
download | gcc-65f36ac8689fcf7c2794b4693bd921fe6893dfe1.zip gcc-65f36ac8689fcf7c2794b4693bd921fe6893dfe1.tar.gz gcc-65f36ac8689fcf7c2794b4693bd921fe6893dfe1.tar.bz2 |
re PR c++/4286 (Internal error: Segmentation fault)
* 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
-rw-r--r-- | gcc/cp/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 4 | ||||
-rw-r--r-- | gcc/cp/search.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/local1.C | 25 |
4 files changed, 46 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 91d3dc6..a3aa99e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 70fcf45..9b1c355 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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))) { diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 22d5332..10ebc73 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -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 index 0000000..85b0056 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local1.C @@ -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> (); +} |