[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / ext / vector29.C
blob4a130092a3f17ddedc69d20f7907825840d2e25f
1 // PR c++/69022 - attribute vector_size ignored with dependent bytes
2 // { dg-do compile }
4 template <int N>
5 struct A { static const int X = N; };
7 #if __cplusplus >= 201202L
8 #  define ASSERT(e) static_assert (e, #e)
9 #else
10 #  define ASSERT(e)   \
11   do { struct S { bool: !!(e); } asrt; (void)&asrt; } while (0)
12 #endif
14 template <class T, int N>
15 struct B: A<N>
17 #if __cplusplus >= 201202L
18   using A<N>::X;
19 #  define VecSize X
20 #else
21 #  define VecSize A<N>::X
22 #endif
24     static void foo ()
25     {
26         char a __attribute__ ((vector_size (N)));
27         ASSERT (sizeof a == N);
29         T b __attribute__ ((vector_size (N)));
30         ASSERT (sizeof b == N);
31     }
33     static void bar ()
34     {
35         char c1 __attribute__ ((vector_size (VecSize)));
36         ASSERT (sizeof c1 == VecSize);
38         char c2 __attribute__ ((vector_size (A<N>::X)));
39         ASSERT (sizeof c2 == A<N>::X);
41         T d1 __attribute__ ((vector_size (VecSize)));
42         ASSERT (sizeof d1 == VecSize);
44         T d2 __attribute__ ((vector_size (A<N>::X)));
45         ASSERT (sizeof d2 == A<N>::X);
46     }
49 void bar ()
51     B<int, 16>::foo ();
52     B<int, 16>::bar ();