[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / g++.dg / lookup / name-clash11.C
blob28ce4c937c5365ec2e2b996a151948c5e7755ee0
1 // PR c++/69023 - bitset whose name is used in constant-expression rejected
2 // Test also verifies the correct evaluation of the expressions with
3 // -fpermissive.
4 // { dg-options "-fpermissive" }
6 #if __cplusplus >= 201103L
7 #  define ASSERT(e) static_assert (e, #e)
8 #else
9 #  define ASSERT(e)                                             \
10   do { struct S { bool: !!(e); } asrt; (void)&asrt; } while (0)
11 #endif
14 void test_bitset ()
16   int x;                        // { dg-warning "changes meaning" }
18   {
19     struct S {
20       int x: sizeof x;          // { dg-warning "declaration" }
21     };
22   }
25 void test_enum ()
27   // Also exercise (not covered by c++/69023):
28   int y;                        // { dg-warning "changes meaning" }
29   {
30     struct S {
31       enum E {
32         y = sizeof y            // { dg-warning "declaration" }
33       };
35       // Verify the enumerator has the correct value.
36       void test () { ASSERT (y == sizeof (int)); }
37     };
38   }
41 void test_alignas ()
43   enum { A = 16 };              // { dg-warning "changes meaning" }
44   {
45     struct S {
46 #if __cplusplus >= 201103L
47       alignas (A)
48 #else
49       __attribute__ ((aligned (A)))
50 #endif
51       int A;                    // { dg-warning "declaration" }
53       // Verify the member has the correct alignment.
54       void test () { ASSERT (__alignof__ (this->A) == 16); }
55     };
56   }
59 void test_array ()
61   enum { A = 16 };              // { dg-warning "changes meaning" }
62   {
63     struct S {
64       int A [A];                // { dg-warning "declaration" }
66       // Verify the member has the correct alignment.
67       void test () { ASSERT (sizeof (this->A) == 16 * sizeof (int)); }
68     };
69   } 
72 void test_vector ()
74   enum { A = 16 };              // { dg-warning "changes meaning" }
75   {
76     struct S {
77       int A __attribute__ ((vector_size (A))); // { dg-warning "declaration" }
79       // Verify the member has the correct size.
80       void test () { ASSERT (sizeof (this->A) == 16); }
81     };
82   }