Debian Codegraph @

gcc/testsuite/g++.dg/template/non-dependent26.C

raw
1 // Verify non-dependent assignment expressions are recognized as such
2 // and are checked ahead of time.
3 // PR c++/63198
4 // { dg-do compile { target c++11 } }
5
6 struct X { using t1 = int; };
7 struct Y { X operator=(const Y&); } y;
8 template<class T> void f1(decltype(y = y)::t1);
9
10 int n;
11 template<class T> void f2(decltype(n = n)::t1); // { dg-error "not a class" }
12 template<class T> void f3(decltype(n += n)::t1); // { dg-error "not a class" }
13
14 template<class T>
15 void g() {
16 const int n;
17 n = 42; // { dg-error "read-only" }
18
19 const X x;
20 x = {}; // { dg-error "no match" }
21
22 const Y y;
23 y = {}; // { dg-error "no match" }
24 Y{} = X{}; // { dg-error "no match" }
25 }