Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/nontype6.C

raw
1 // PR c++/113266, PR c++/116911
2 // { dg-do compile }
3
4 template <int &> struct a {};
5 static int guard1;
6 a<guard1> b; // { dg-error "constant-expression|invalid" "" { target c++98_only } }
7
8 namespace {
9 int guard2;
10 }
11 a<guard2> c; // OK in C++98 because guard2 has external linkage
12 // OK since C++11 because we can refer to an internal linkage decl
13
14 void nolinkage() {
15 static int guard3;
16 a<guard3> d; // { dg-error "constant-expression|invalid" "" { target c++98_only } }
17 // { dg-error "constant expression|no linkage" "" { target { c++11 && c++14_down } } .-1 }
18 // OK since C++17 since we can now refer to no-linkage decls
19 }