ipa-cp: Perform operations in the appropriate types (PR 118097)
[gcc.git] / gcc / testsuite / g++.dg / template / non-dependent26.C
blob1faa39a4b1ae668b3571e1ed60c502adca79f515
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 } }
6 struct X { using t1 = int; };
7 struct Y { X operator=(const Y&); } y;
8 template<class T> void f1(decltype(y = y)::t1);
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" }
14 template<class T>
15 void g() {
16   const int n;
17   n = 42; // { dg-error "read-only" }
19   const X x;
20   x = {}; // { dg-error "no match" }
22   const Y y;
23   y = {}; // { dg-error "no match" }
24   Y{} = X{}; // { dg-error "no match" }