aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/vector29.C
blob: 4a130092a3f17ddedc69d20f7907825840d2e25f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// PR c++/69022 - attribute vector_size ignored with dependent bytes
// { dg-do compile }

template <int N>
struct A { static const int X = N; };

#if __cplusplus >= 201202L
#  define ASSERT(e) static_assert (e, #e)
#else
#  define ASSERT(e)   \
  do { struct S { bool: !!(e); } asrt; (void)&asrt; } while (0)
#endif

template <class T, int N>
struct B: A<N>
{
#if __cplusplus >= 201202L
  using A<N>::X;
#  define VecSize X
#else
#  define VecSize A<N>::X
#endif

    static void foo ()
    {
        char a __attribute__ ((vector_size (N)));
        ASSERT (sizeof a == N);

        T b __attribute__ ((vector_size (N)));
        ASSERT (sizeof b == N);
    }

    static void bar ()
    {
        char c1 __attribute__ ((vector_size (VecSize)));
        ASSERT (sizeof c1 == VecSize);

        char c2 __attribute__ ((vector_size (A<N>::X)));
        ASSERT (sizeof c2 == A<N>::X);

        T d1 __attribute__ ((vector_size (VecSize)));
        ASSERT (sizeof d1 == VecSize);

        T d2 __attribute__ ((vector_size (A<N>::X)));
        ASSERT (sizeof d2 == A<N>::X);
    }
};

void bar ()
{
    B<int, 16>::foo ();
    B<int, 16>::bar ();
}