Debian Codegraph @

gcc/testsuite/g++.dg/ext/vector29.C

raw
1 // PR c++/69022 - attribute vector_size ignored with dependent bytes
2 // { dg-do compile }
3
4 template <int N>
5 struct A { static const int X = N; };
6
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
13
14 template <class T, int N>
15 struct B: A<N>
16 {
17 #if __cplusplus >= 201202L
18 using A<N>::X;
19 # define VecSize X
20 #else
21 # define VecSize A<N>::X
22 #endif
23
24 static void foo ()
25 {
26 char a __attribute__ ((vector_size (N)));
27 ASSERT (sizeof a == N);
28
29 T b __attribute__ ((vector_size (N)));
30 ASSERT (sizeof b == N);
31 }
32
33 static void bar ()
34 {
35 char c1 __attribute__ ((vector_size (VecSize)));
36 ASSERT (sizeof c1 == VecSize);
37
38 char c2 __attribute__ ((vector_size (A<N>::X)));
39 ASSERT (sizeof c2 == A<N>::X);
40
41 T d1 __attribute__ ((vector_size (VecSize)));
42 ASSERT (sizeof d1 == VecSize);
43
44 T d2 __attribute__ ((vector_size (A<N>::X)));
45 ASSERT (sizeof d2 == A<N>::X);
46 }
47 };
48
49 void bar ()
50 {
51 B<int, 16>::foo ();
52 B<int, 16>::bar ();
53 }