mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/51228 (ICE with transparent union)
PR c++/51228 * c-common.c (handle_transparent_union_attribute): Check the first field if the type is complete. From-SVN: r182494
This commit is contained in:
parent
1784915af2
commit
d58d6eb5ec
|
@ -1,3 +1,9 @@
|
||||||
|
2011-12-19 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/51228
|
||||||
|
* c-common.c (handle_transparent_union_attribute): Check the first
|
||||||
|
field if the type is complete.
|
||||||
|
|
||||||
2011-12-15 Jonathan Wakely <jwakely.gcc@gmail.com>
|
2011-12-15 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
PR libstdc++/51365
|
PR libstdc++/51365
|
||||||
|
|
|
@ -6287,13 +6287,27 @@ handle_transparent_union_attribute (tree *node, tree name,
|
||||||
|
|
||||||
if (TREE_CODE (type) == UNION_TYPE)
|
if (TREE_CODE (type) == UNION_TYPE)
|
||||||
{
|
{
|
||||||
/* When IN_PLACE is set, leave the check for FIELDS and MODE to
|
/* Make sure that the first field will work for a transparent union.
|
||||||
the code in finish_struct. */
|
If the type isn't complete yet, leave the check to the code in
|
||||||
|
finish_struct. */
|
||||||
|
if (TYPE_SIZE (type))
|
||||||
|
{
|
||||||
|
tree first = first_field (type);
|
||||||
|
if (first == NULL_TREE
|
||||||
|
|| DECL_ARTIFICIAL (first)
|
||||||
|
|| TYPE_MODE (type) != DECL_MODE (first))
|
||||||
|
goto ignored;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
|
if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
|
||||||
{
|
{
|
||||||
if (TYPE_FIELDS (type) == NULL_TREE
|
/* If the type isn't complete yet, setting the flag
|
||||||
|| c_dialect_cxx ()
|
on a variant wouldn't ever be checked. */
|
||||||
|| TYPE_MODE (type) != DECL_MODE (TYPE_FIELDS (type)))
|
if (!TYPE_SIZE (type))
|
||||||
|
goto ignored;
|
||||||
|
|
||||||
|
/* build_duplicate_type doesn't work for C++. */
|
||||||
|
if (c_dialect_cxx ())
|
||||||
goto ignored;
|
goto ignored;
|
||||||
|
|
||||||
/* A type variant isn't good enough, since we don't a cast
|
/* A type variant isn't good enough, since we don't a cast
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2011-12-19 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/51228
|
||||||
|
* c-c++-common/transparent-union-1.c: New.
|
||||||
|
|
||||||
2011-12-19 Eric Botcazou <ebotcazou@adacore.com>
|
2011-12-19 Eric Botcazou <ebotcazou@adacore.com>
|
||||||
|
|
||||||
PR tree-optimization/51580
|
PR tree-optimization/51580
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
/* PR c++/51228 */
|
||||||
|
|
||||||
|
typedef union {} U __attribute__((transparent_union)); /* { dg-warning "ignored" } */
|
||||||
|
|
||||||
|
void foo(U u) {}
|
Loading…
Reference in New Issue