mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-24 17:29:33 +08:00
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
This commit is contained in:
parent
5ee4950e46
commit
65f36ac868
@ -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.
|
||||
|
@ -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)))
|
||||
{
|
||||
|
@ -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. */
|
||||
|
25
gcc/testsuite/g++.dg/template/local1.C
Normal file
25
gcc/testsuite/g++.dg/template/local1.C
Normal file
@ -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> ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user