Debian Codegraph @

gcc/testsuite/g++.dg/concepts/generic-fn-err.C

raw
1 // { dg-do compile { target c++17 } }
2 // { dg-options "-fconcepts" }
3
4 template<typename T>
5 concept C = __is_class(T);
6
7 template<int N>
8 concept Int = true;
9
10 template<template<typename> class X>
11 concept Template = true;
12
13 void f1(Int) { } // { dg-error "does not constrain a type" }
14 void f2(Template) { } // { dg-error "does not constrain a type" }
15
16 struct S { };
17
18 struct S1 {
19 void f1(auto x) { }
20 void f2(C auto x) { }
21
22 void f3(auto x) { }
23 void f3(C auto x) { }
24 };
25
26 template<C T>
27 struct S2 {
28 void f1(auto x) { }
29 void f2(C auto x) { }
30
31 void h1(auto x);
32 void h2(C auto x);
33
34 template<C U>
35 void g(T t, U u) { }
36 };
37
38 int main() {
39 S s;
40
41 S1 s1;
42 s1.f2(0); // { dg-error "matching" }
43
44 S2<S> s2;
45 s2.f2(0); // { dg-error "matching" }
46 s2.h2(0); // { dg-error "matching" }
47
48 s2.g(s, 0); // { dg-error "matching" }
49 s2.g(0, s); // { dg-error "matching" }
50 }