re PR c++/30302 (ICE with invalid member in anonymous struct)
/cp 2007-09-03 Paolo Carlini <pcarlini@suse.de> PR c++/30302 * semantics.c (finish_id_expression): Check that path != NULL_TREE before using TYPE_BINFO on it. * class.c (finish_struct_anon): Deal correctly with anonymous structs (vs unions, as GNU extension) in error messages. /testsuite 2007-09-03 Paolo Carlini <pcarlini@suse.de> PR c++/30302 * g++.dg/ext/anon-struct5.C: New. From-SVN: r128145
This commit is contained in:
parent
13678df87b
commit
61fdc9d746
|
@ -1,3 +1,11 @@
|
||||||
|
2007-09-05 Paolo Carlini <pcarlini@suse.de>
|
||||||
|
|
||||||
|
PR c++/30302
|
||||||
|
* semantics.c (finish_id_expression): Use context_for_name_lookup
|
||||||
|
insted of DECL_CONTEXT, to see through anonymous structs and unions.
|
||||||
|
* class.c (finish_struct_anon): Deal correctly with anonymous
|
||||||
|
structs (vs unions, as GNU extension) in error messages.
|
||||||
|
|
||||||
2007-09-05 Jan Hubicka <jh@suse.cz>
|
2007-09-05 Jan Hubicka <jh@suse.cz>
|
||||||
|
|
||||||
* cp/sematics.c (expand_body): Remove unnecesary import_export_decl
|
* cp/sematics.c (expand_body): Remove unnecesary import_export_decl
|
||||||
|
|
|
@ -2458,6 +2458,7 @@ finish_struct_anon (tree t)
|
||||||
if (DECL_NAME (field) == NULL_TREE
|
if (DECL_NAME (field) == NULL_TREE
|
||||||
&& ANON_AGGR_TYPE_P (TREE_TYPE (field)))
|
&& ANON_AGGR_TYPE_P (TREE_TYPE (field)))
|
||||||
{
|
{
|
||||||
|
bool is_union = TREE_CODE (TREE_TYPE (field)) == UNION_TYPE;
|
||||||
tree elt = TYPE_FIELDS (TREE_TYPE (field));
|
tree elt = TYPE_FIELDS (TREE_TYPE (field));
|
||||||
for (; elt; elt = TREE_CHAIN (elt))
|
for (; elt; elt = TREE_CHAIN (elt))
|
||||||
{
|
{
|
||||||
|
@ -2475,15 +2476,29 @@ finish_struct_anon (tree t)
|
||||||
|
|
||||||
if (TREE_CODE (elt) != FIELD_DECL)
|
if (TREE_CODE (elt) != FIELD_DECL)
|
||||||
{
|
{
|
||||||
pedwarn ("%q+#D invalid; an anonymous union can "
|
if (is_union)
|
||||||
"only have non-static data members", elt);
|
pedwarn ("%q+#D invalid; an anonymous union can "
|
||||||
|
"only have non-static data members", elt);
|
||||||
|
else
|
||||||
|
pedwarn ("%q+#D invalid; an anonymous struct can "
|
||||||
|
"only have non-static data members", elt);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TREE_PRIVATE (elt))
|
if (TREE_PRIVATE (elt))
|
||||||
pedwarn ("private member %q+#D in anonymous union", elt);
|
{
|
||||||
|
if (is_union)
|
||||||
|
pedwarn ("private member %q+#D in anonymous union", elt);
|
||||||
|
else
|
||||||
|
pedwarn ("private member %q+#D in anonymous struct", elt);
|
||||||
|
}
|
||||||
else if (TREE_PROTECTED (elt))
|
else if (TREE_PROTECTED (elt))
|
||||||
pedwarn ("protected member %q+#D in anonymous union", elt);
|
{
|
||||||
|
if (is_union)
|
||||||
|
pedwarn ("protected member %q+#D in anonymous union", elt);
|
||||||
|
else
|
||||||
|
pedwarn ("protected member %q+#D in anonymous struct", elt);
|
||||||
|
}
|
||||||
|
|
||||||
TREE_PRIVATE (elt) = TREE_PRIVATE (field);
|
TREE_PRIVATE (elt) = TREE_PRIVATE (field);
|
||||||
TREE_PROTECTED (elt) = TREE_PROTECTED (field);
|
TREE_PROTECTED (elt) = TREE_PROTECTED (field);
|
||||||
|
|
|
@ -2928,7 +2928,7 @@ finish_id_expression (tree id_expression,
|
||||||
{
|
{
|
||||||
if (DECL_P (decl) && DECL_NONLOCAL (decl)
|
if (DECL_P (decl) && DECL_NONLOCAL (decl)
|
||||||
&& DECL_CLASS_SCOPE_P (decl)
|
&& DECL_CLASS_SCOPE_P (decl)
|
||||||
&& DECL_CONTEXT (decl) != current_class_type)
|
&& context_for_name_lookup (decl) != current_class_type)
|
||||||
{
|
{
|
||||||
tree path;
|
tree path;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2007-09-05 Paolo Carlini <pcarlini@suse.de>
|
||||||
|
|
||||||
|
PR c++/30302
|
||||||
|
* g++.dg/ext/anon-struct5.C: New.
|
||||||
|
|
||||||
2007-09-05 Uros Bizjak <ubizjak@gmail.com>
|
2007-09-05 Uros Bizjak <ubizjak@gmail.com>
|
||||||
|
|
||||||
* gcc.dg/i386-cpuid.h: Remove.
|
* gcc.dg/i386-cpuid.h: Remove.
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// PR c++/30302
|
||||||
|
|
||||||
|
struct A
|
||||||
|
{
|
||||||
|
struct { static int i; }; // { dg-error "prohibits anonymous structs|an anonymous struct" }
|
||||||
|
void foo() { i; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct B
|
||||||
|
{
|
||||||
|
union { static int i; }; // { dg-error "an anonymous union|member of a union" }
|
||||||
|
void foo() { i; }
|
||||||
|
};
|
Loading…
Reference in New Issue