Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/decltype-auto5.C

raw
1 // PR c++/102229
2 // { dg-do compile { target c++14 } }
3
4 struct S {
5 constexpr static decltype(auto) x = 42;
6 const constexpr static decltype(auto) y = 42; // { dg-error "cannot be cv-qualified" }
7
8 constexpr decltype(auto) mfn1 () { return 0; }
9 const constexpr decltype(auto) mfn2 () { return 0; } // { dg-error "cannot be cv-qualified" }
10 };
11
12 constexpr decltype(auto) i = 42;
13 const constexpr decltype(auto) j = 42; // { dg-error "cannot be cv-qualified" }
14
15 constexpr decltype(auto) fn() { return 42; }
16 const decltype(auto) fn2() { return 42; } // { dg-error "cannot be cv-qualified" }
17
18 auto constexpr foo() -> const decltype(auto) // { dg-error "cannot be cv-qualified" }
19 {
20 return 0;
21 }
22
23 #if __cpp_concepts
24 template<typename>
25 concept C = true;
26
27 constexpr C decltype(auto) x1 = 0;
28 const constexpr C decltype(auto) x2 = 0; // { dg-error "cannot be cv-qualified" "" { target c++20 } }
29
30 constexpr C decltype(auto) fn3() { return 0; }
31 const constexpr C decltype(auto) fn4() { return 0; } // { dg-error "cannot be cv-qualified" "" { target c++20 } }
32 #endif
33
34 template<const decltype(auto) = 42> // { dg-error "cannot be cv-qualified" }
35 void g ();