Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/constinit13.C

raw
1 // PR c++/91644 - ICE with constinit in function template.
2 // { dg-do compile { target c++11 } }
3
4 template <typename T>
5 static void fn1 ()
6 {
7 static __constinit auto v1 = 0;
8 static __constinit int v2 = 0;
9 }
10
11 int nonconst;
12
13 template <typename T>
14 static void fn2 ()
15 {
16 static __constinit auto v1 = nonconst; // { dg-error "does not have a constant initializer|not usable" }
17 static __constinit int v2 = nonconst; // { dg-error "does not have a constant initializer|not usable" }
18 }
19
20 template <typename T>
21 static void fn3 ()
22 {
23 static __constinit T v1 = 0;
24 static __constinit T v2 = nonconst; // { dg-error "does not have a constant initializer|not usable" }
25 }
26
27 void
28 g ()
29 {
30 fn1<int>();
31 fn2<int>();
32 fn3<int>();
33 }