Commit 6f87580f by Nathan Sidwell Committed by Nathan Sidwell

[PR c++/84962] ICE with anon-struct member

https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00961.html
	PR c++/84962
	* name-lookup.c (pushdecl_class_level): Push anon-struct's
	member_vec, if there is one.

	PR c++/84962
	* g++.dg/lookup/pr84962.C: New.

From-SVN: r258686
parent 5770bbac
2018-03-20 Nathan Sidwell <nathan@acm.org> 2018-03-20 Nathan Sidwell <nathan@acm.org>
PR c++/84962
* name-lookup.c (pushdecl_class_level): Push anon-struct's
member_vec, if there is one.
PR c++/84970 PR c++/84970
* cp-tree.h (lookup_list_keep): Declare. * cp-tree.h (lookup_list_keep): Declare.
* tree.c (lookup_list_keep): New, broken out of ... * tree.c (lookup_list_keep): New, broken out of ...
......
...@@ -4490,16 +4490,30 @@ pushdecl_class_level (tree x) ...@@ -4490,16 +4490,30 @@ pushdecl_class_level (tree x)
/* If X is an anonymous aggregate, all of its members are /* If X is an anonymous aggregate, all of its members are
treated as if they were members of the class containing the treated as if they were members of the class containing the
aggregate, for naming purposes. */ aggregate, for naming purposes. */
tree f; location_t save_location = input_location;
tree anon = TREE_TYPE (x);
for (f = TYPE_FIELDS (TREE_TYPE (x)); f; f = DECL_CHAIN (f)) if (vec<tree, va_gc> *member_vec = CLASSTYPE_MEMBER_VEC (anon))
{ for (unsigned ix = member_vec->length (); ix--;)
location_t save_location = input_location; {
input_location = DECL_SOURCE_LOCATION (f); tree binding = (*member_vec)[ix];
if (!pushdecl_class_level (f)) if (STAT_HACK_P (binding))
is_valid = false; {
input_location = save_location; if (!pushdecl_class_level (STAT_TYPE (binding)))
is_valid = false;
binding = STAT_DECL (binding);
}
if (!pushdecl_class_level (binding))
is_valid = false;
} }
else
for (tree f = TYPE_FIELDS (anon); f; f = DECL_CHAIN (f))
if (TREE_CODE (f) == FIELD_DECL)
{
input_location = DECL_SOURCE_LOCATION (f);
if (!pushdecl_class_level (f))
is_valid = false;
}
input_location = save_location;
} }
timevar_cond_stop (TV_NAME_LOOKUP, subtime); timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return is_valid; return is_valid;
......
2018-03-20 Nathan Sidwell <nathan@acm.org> 2018-03-20 Nathan Sidwell <nathan@acm.org>
PR c++/84962
* g++.dg/lookup/pr84962.C: New.
PR c++/84970 PR c++/84970
* g++.dg/lookup/pr84970.C: New. * g++.dg/lookup/pr84970.C: New.
......
// PR c++/84952 ICE with anon-struct having member fns
// { dg-do compile { target c++11 } }
// { dg-additional-options -Wno-pedantic }
struct X {
struct
{
template <typename> int a ();
// { dg-error "can only have" "" { target *-*-* } .-1 }
};
int : a; // { dg-error "non-integral" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment