* attribs.c (decl_attributes): Leave ATTR_FLAG_TYPE_IN_PLACE
alone if it's the naming decl for the type's main variant.
* cp/decl.c (grokdeclarator): Allow a typedef of an unnamed struct
to name the struct for linkage purposes even if it has attributes.
(start_decl): In that case, set ATTR_FLAG_TYPE_IN_PLACE.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132681
138bc75d-0d04-0410-961f-
82ee72b054a4
+2008-02-26 Jason Merrill <jason@redhat.com>
+
+ PR c++/35315
+ * attribs.c (decl_attributes): Leave ATTR_FLAG_TYPE_IN_PLACE
+ alone if it's the naming decl for the type's main variant.
+
2008-02-26 Tom Tromey <tromey@redhat.com>
* system.h (USE_MAPPED_LOCATION): Poison.
if (spec->type_required && DECL_P (*anode))
{
anode = &TREE_TYPE (*anode);
- flags &= ~(int) ATTR_FLAG_TYPE_IN_PLACE;
+ /* Allow ATTR_FLAG_TYPE_IN_PLACE for the type's naming decl. */
+ if (!(TREE_CODE (*anode) == TYPE_DECL
+ && *anode == TYPE_NAME (TYPE_MAIN_VARIANT
+ (TREE_TYPE (*anode)))))
+ flags &= ~(int) ATTR_FLAG_TYPE_IN_PLACE;
}
if (spec->function_type_required && TREE_CODE (*anode) != FUNCTION_TYPE
+2008-02-26 Jason Merrill <jason@redhat.com>
+
+ PR c++/35315
+ * decl.c (grokdeclarator): Allow a typedef of an unnamed struct
+ to name the struct for linkage purposes even if it has attributes.
+ (start_decl): In that case, set ATTR_FLAG_TYPE_IN_PLACE.
+
2008-02-26 Tom Tromey <tromey@redhat.com>
* parser.c (eof_token): Remove old location code.
2008-02-12 Jason Merrill <jason@redhat.com>
PR c++/34824
- * call.c (convert_like_real): Pass LOOKUP_ONLYCONVERTING to build_temp
+ * call.c (convert_like_real): Pass LOOKUP_NO_CONVERSION to build_temp
if we're doing conversions to call a user-defined conversion function.
2008-02-12 Steven Bosscher <steven@gcc.gnu.org>
tree type;
tree context;
bool was_public;
+ int flags;
*pushed_scope_p = NULL_TREE;
TREE_STATIC (decl) = 1;
}
+ /* If this is a typedef that names the class for linkage purposes
+ (7.1.3p8), apply any attributes directly to the type. */
+ if (TREE_CODE (decl) == TYPE_DECL
+ && TAGGED_TYPE_P (TREE_TYPE (decl))
+ && decl == TYPE_NAME (TYPE_MAIN_VARIANT (TREE_TYPE (decl))))
+ flags = ATTR_FLAG_TYPE_IN_PLACE;
+ else
+ flags = 0;
+
/* Set attributes here so if duplicate decl, will have proper attributes. */
- cplus_decl_attributes (&decl, attributes, 0);
+ cplus_decl_attributes (&decl, attributes, flags);
/* Dllimported symbols cannot be defined. Static data members (which
can be initialized in-class and dllimported) go through grokfield,
&& TYPE_NAME (type)
&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
&& TYPE_ANONYMOUS_P (type)
- /* Don't do this if there are attributes. */
- && (!attrlist || !*attrlist)
&& cp_type_quals (type) == TYPE_UNQUALIFIED)
{
tree oldname = TYPE_NAME (type);
--- /dev/null
+// PR c++/35315
+
+typedef union { int i; } U __attribute__((transparent_union));
+
+static void foo(U) {}
+static void foo(int) {}
+
+void bar()
+{
+ foo(0);
+}