Commit 317c435f by Jason Merrill Committed by Jason Merrill

re PR c++/35315 (ICE with attribute transparent_union)

        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.
        * 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.

From-SVN: r132681
parent f82c41ea
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.
......
......@@ -280,7 +280,11 @@ decl_attributes (tree *node, tree attributes, int flags)
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.
......@@ -181,7 +188,7 @@
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>
......
......@@ -3957,6 +3957,7 @@ start_decl (const cp_declarator *declarator,
tree type;
tree context;
bool was_public;
int flags;
*pushed_scope_p = NULL_TREE;
......@@ -4018,8 +4019,17 @@ start_decl (const cp_declarator *declarator,
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,
......@@ -8556,8 +8566,6 @@ grokdeclarator (const cp_declarator *declarator,
&& 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);
......
// PR c++/35315
typedef union { int i; } U __attribute__((transparent_union));
static void foo(U) {}
static void foo(int) {}
void bar()
{
foo(0);
}
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