This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/36410
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 19 Nov 2008 16:34:39 -0500
- Subject: C++ PATCH for c++/36410
This is the member version of PR 35315, which was fixed by applying type
attributes directly to the underlying type of a naming typedef for a
formerly anonymous class. When I fixed start_decl I didn't think to fix
grokfield at the same time, so this is the parallel change.
Tested x86_64-pc-linux-gnu, applied to trunk. I didn't apply the 35315
patch to 4.3, so I think I won't apply this either unless someone asks
for it.
2008-11-19 Jason Merrill <jason@redhat.com>
PR c++/36410
* decl2.c (grokfield): Pass ATTR_FLAG_TYPE_IN_PLACE for a typedef
that names a class for linkage purposes.
* g++.dg/ext/attrib32.C: Add member typedef case.
Index: cp/decl2.c
===================================================================
*** cp/decl2.c (revision 142004)
--- cp/decl2.c (working copy)
*************** grokfield (const cp_declarator *declarat
*** 803,809 ****
value = push_template_decl (value);
if (attrlist)
! cplus_decl_attributes (&value, attrlist, 0);
return value;
}
--- 803,819 ----
value = push_template_decl (value);
if (attrlist)
! {
! int attrflags = 0;
!
! /* If this is a typedef that names the class for linkage purposes
! (7.1.3p8), apply any attributes directly to the type. */
! if (TAGGED_TYPE_P (TREE_TYPE (value))
! && value == TYPE_NAME (TYPE_MAIN_VARIANT (TREE_TYPE (value))))
! attrflags = ATTR_FLAG_TYPE_IN_PLACE;
!
! cplus_decl_attributes (&value, attrlist, attrflags);
! }
return value;
}
Index: testsuite/g++.dg/ext/attrib32.C
===================================================================
*** testsuite/g++.dg/ext/attrib32.C (revision 142004)
--- testsuite/g++.dg/ext/attrib32.C (working copy)
*************** void bar2(U1 u1, U2 u2)
*** 20,22 ****
--- 20,36 ----
foo2(u1);
foo2(u2);
}
+
+ // PR c++/36410
+ struct A
+ {
+ typedef union
+ {
+ int i;
+ } B __attribute__((transparent_union));
+ };
+
+ void foo(A::B b)
+ {
+ b.i;
+ }