+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>
* cp/sematics.c (expand_body): Remove unnecesary import_export_decl
if (DECL_NAME (field) == NULL_TREE
&& ANON_AGGR_TYPE_P (TREE_TYPE (field)))
{
+ bool is_union = TREE_CODE (TREE_TYPE (field)) == UNION_TYPE;
tree elt = TYPE_FIELDS (TREE_TYPE (field));
for (; elt; elt = TREE_CHAIN (elt))
{
if (TREE_CODE (elt) != FIELD_DECL)
{
- pedwarn ("%q+#D invalid; an anonymous union can "
- "only have non-static data members", elt);
+ if (is_union)
+ 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;
}
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))
- 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_PROTECTED (elt) = TREE_PROTECTED (field);