diff options
author | Jason Merrill <jason@redhat.com> | 2011-06-20 10:40:19 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-06-20 10:40:19 -0400 |
commit | 053225431604d09cbe1d1495581b71a85a72dd1f (patch) | |
tree | 2582cba7aba4912881fdb6ed06448bc6d805f397 /gcc | |
parent | 2602f8fe61dcf2388890bbbdb938e46ce9d2936b (diff) | |
download | gcc-053225431604d09cbe1d1495581b71a85a72dd1f.zip gcc-053225431604d09cbe1d1495581b71a85a72dd1f.tar.gz gcc-053225431604d09cbe1d1495581b71a85a72dd1f.tar.bz2 |
re PR c++/48138 (__attribute__((aligned)) should give an error when applied to a typedef or template parameter, at least in C++0x mode.)
PR c++/48138
* tree.c (strip_typedefs): Use build_aligned_type.
From-SVN: r175215
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/tree.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/attr-aligned01.C | 20 |
4 files changed, 36 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 87e5164..d88dc60 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-06-20 Jason Merrill <jason@redhat.com> + PR c++/48138 + * tree.c (strip_typedefs): Use build_aligned_type. + PR c++/49205 * call.c (sufficient_parms_p): Allow parameter packs too. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index c1824b4..3100508 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1167,6 +1167,16 @@ strip_typedefs (tree t) if (!result) result = TYPE_MAIN_VARIANT (t); + if (TYPE_USER_ALIGN (t) != TYPE_USER_ALIGN (result) + || TYPE_ALIGN (t) != TYPE_ALIGN (result)) + { + gcc_assert (TYPE_USER_ALIGN (t)); + if (TYPE_ALIGN (t) == TYPE_ALIGN (result)) + result = build_variant_type_copy (result); + else + result = build_aligned_type (result, TYPE_ALIGN (t)); + TYPE_USER_ALIGN (result) = true; + } if (TYPE_ATTRIBUTES (t)) result = cp_build_type_attribute_variant (result, TYPE_ATTRIBUTES (t)); return cp_build_qualified_type (result, cp_type_quals (t)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index abc6245..99d4d3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-06-20 Jason Merrill <jason@redhat.com> + PR c++/48138 + * g++.dg/ext/attr-aligned01.C: New. + PR c++/49205 * g++.dg/cpp0x/variadic-default.C: New. diff --git a/gcc/testsuite/g++.dg/ext/attr-aligned01.C b/gcc/testsuite/g++.dg/ext/attr-aligned01.C new file mode 100644 index 0000000..a051c6e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attr-aligned01.C @@ -0,0 +1,20 @@ +// PR c++/48138 +// { dg-options -std=c++0x } + +#define ALIGNED(x) __attribute__((aligned(x))) +#define SA(X) static_assert ((X),#X) + +template<typename T> +void type_alignment(const T&) { + struct { char c; T t; } s; + SA((char*)&s.t - (char*)&s.c == 8); +} + +int main() { + typedef char unaligned[15]; + typedef char aligned[15] ALIGNED(8); + + aligned z; + type_alignment(z); + type_alignment<unaligned ALIGNED(8)>(z); +} |