2 // { dg-options "-std=c++2a" }
8 concept Bottom = false;
11 concept Class = __is_class(T);
14 concept Number = true;
16 template<template<typename> class T>
17 concept Template = true;
21 Type x1 = 0; // { dg-error "expected 'auto'" }
24 Number x3 = 0; // { dg-error "does not constrain a type" }
25 Template x4 = 0; // { dg-error "does not constrain a type" }
27 Type const& x5 = 0; // { dg-error "expected 'auto'" }
28 const Type& x6 = 0; // { dg-error "expected 'auto'" }
29 Type auto const& x7 = 0;
30 const Type auto& x8 = 0;
31 Type const auto& x9 = 0; // { dg-error "expected 'auto'|two or more data types" }
33 template<Type T> // OK: T is a type parameter.
36 template<Number N> // { dg-error "does not constrain a type" }
39 template<Template X> // { dg-error "does not constrain a type" }
42 template<Type auto N> // OK: N is a non-type parameter.
45 template<Bottom auto N> // OK: but never usable.
50 f5<0>(); // { dg-error "no matching function for call | constraints not satisfied" }
53 Type f6() { return 0; } // { dg-error "expected 'auto'" }
54 static_assert(__is_same_as(decltype(f6), int()));
56 Type auto f7() { return 0; }
57 static_assert(__is_same_as(decltype(f7), int()));
59 Type f8() { return 0; } // { dg-error "expected 'auto'" }
60 auto f9() -> Type { return 0; } // { dg-error "expected 'auto'" }
62 Type f10() { } // { dg-error "expected 'auto'" }
63 auto f11() -> Type { } // { dg-error "expected" }
65 Number f12(); // { dg-error "does not constrain a type" }
66 auto f13() -> Number; // { dg-error "does not constrain a type" }
68 Template f14(); // { dg-error "does not constrain a type" }
69 auto f15() -> Template; // { dg-error "does not constrain a type" }
71 Type f16() { return 0; } // { dg-error "expected 'auto'" }
72 auto f17() -> Type { return 0; } // { dg-error "expected 'auto'" }
74 // Abbreviated function templates
76 void f18(Class x) { } // { dg-error "expected 'auto'" }
77 void f19(Class auto x) { }
78 void f20(Class auto x, Class auto y) { }
82 f19(0); // { dg-error "" }
84 f20(0, empty{}); // { dg-error "" }
85 f20(empty{}, empty{});
88 // Abbreviated function redeclarations
90 // Functionally equivalent but not equivalent.
91 void f21(Class auto x);
92 template<Class T> void f21(T x);
96 f21(empty{}); // { dg-error "call of overload | ambiguous" }