diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/ext/alignof2.C')
-rw-r--r-- | gcc/testsuite/g++.dg/ext/alignof2.C | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ext/alignof2.C b/gcc/testsuite/g++.dg/ext/alignof2.C new file mode 100644 index 000000000..8bc8a9c01 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/alignof2.C @@ -0,0 +1,25 @@ +// PRs 16387 and 16389 +// We were treating alignof (sa.a) as alignof (typeof (sa.a)), which is +// wrong for some fields. + +// { dg-do run } + +extern "C" void abort(); + +struct A +{ + double a; +} sa; + +struct B +{ + char c; + double b; +} sb; + +int main() +{ + if (__alignof (sa) != __alignof (sa.a) + || __alignof (sb) != __alignof (sb.b)) + abort(); +} |