Daily bump.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / concepts-p1141.C
blobac240a5b2d5e35c3ff2072791d2e14382f899b49
1 // { dg-do compile }
2 // { dg-options "-std=c++2a" }
4 template<typename T>
5 concept Type = true;
7 template<typename T>
8 concept Bottom = false;
10 template<typename T>
11 concept Class = __is_class(T);
13 template<auto N>
14 concept Number = true;
16 template<template<typename> class T>
17 concept Template = true;
19 struct empty { };
21 Type x1 = 0; // { dg-error "expected 'auto'" }
22 Type auto x2 = 0;
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.
34 void f1(T);
36 template<Number N> // { dg-error "does not constrain a type" }
37 void f2();
39 template<Template X> // { dg-error "does not constrain a type" }
40 void f3();
42 template<Type auto N> // OK: N is a non-type parameter.
43 void f4() { }
45 template<Bottom auto N> // OK: but never usable.
46 void f5();
48 void driver() {
49   f4<0>();
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) { }
80 void driver_1()
82   f19(0); // { dg-error "" }
83   f19(empty{});
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);
94 void driver_2()
96   f21(empty{}); // { dg-error "call of overload | ambiguous" }