diff options
author | Martin Sebor <msebor@redhat.com> | 2015-12-23 21:52:50 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2015-12-23 14:52:50 -0700 |
commit | 7c332a4ee508059a09fa63fdcf755dcad6ccbd50 (patch) | |
tree | 0e9b21b281c38bdaabf611eef5535f79c7088c6e /gcc | |
parent | 97b7f1385a99158f1cd445e6c44bfe70fdad6576 (diff) | |
download | gcc-7c332a4ee508059a09fa63fdcf755dcad6ccbd50.zip gcc-7c332a4ee508059a09fa63fdcf755dcad6ccbd50.tar.gz gcc-7c332a4ee508059a09fa63fdcf755dcad6ccbd50.tar.bz2 |
PR c++/69023 - bitset whose name is used in constant-expression rejected
PR c++/69023 - bitset whose name is used in constant-expression rejected
* g++.dg/lookup/name-clash11.C: New test.
From-SVN: r231938
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/lookup/name-clash11.C | 84 |
2 files changed, 89 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ab9fab..2002f92 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-23 Martin Sebor <msebor@redhat.com> + + PR c++/69023 + * g++.dg/lookup/name-clash11.C: New test. + 2015-12-23 Nathan Sidwell <nathan@acm.org> * gcc.dg/alias-15.c: Revert. diff --git a/gcc/testsuite/g++.dg/lookup/name-clash11.C b/gcc/testsuite/g++.dg/lookup/name-clash11.C new file mode 100644 index 0000000..28ce4c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/lookup/name-clash11.C @@ -0,0 +1,84 @@ +// PR c++/69023 - bitset whose name is used in constant-expression rejected +// Test also verifies the correct evaluation of the expressions with +// -fpermissive. +// { dg-options "-fpermissive" } + +#if __cplusplus >= 201103L +# define ASSERT(e) static_assert (e, #e) +#else +# define ASSERT(e) \ + do { struct S { bool: !!(e); } asrt; (void)&asrt; } while (0) +#endif + + +void test_bitset () +{ + int x; // { dg-warning "changes meaning" } + + { + struct S { + int x: sizeof x; // { dg-warning "declaration" } + }; + } +} + +void test_enum () +{ + // Also exercise (not covered by c++/69023): + int y; // { dg-warning "changes meaning" } + { + struct S { + enum E { + y = sizeof y // { dg-warning "declaration" } + }; + + // Verify the enumerator has the correct value. + void test () { ASSERT (y == sizeof (int)); } + }; + } +} + +void test_alignas () +{ + enum { A = 16 }; // { dg-warning "changes meaning" } + { + struct S { +#if __cplusplus >= 201103L + alignas (A) +#else + __attribute__ ((aligned (A))) +#endif + int A; // { dg-warning "declaration" } + + // Verify the member has the correct alignment. + void test () { ASSERT (__alignof__ (this->A) == 16); } + }; + } +} + +void test_array () +{ + enum { A = 16 }; // { dg-warning "changes meaning" } + { + struct S { + int A [A]; // { dg-warning "declaration" } + + // Verify the member has the correct alignment. + void test () { ASSERT (sizeof (this->A) == 16 * sizeof (int)); } + }; + } +} + +void test_vector () +{ + enum { A = 16 }; // { dg-warning "changes meaning" } + { + struct S { + int A __attribute__ ((vector_size (A))); // { dg-warning "declaration" } + + // Verify the member has the correct size. + void test () { ASSERT (sizeof (this->A) == 16); } + }; + } +} + |