1 // { dg-do compile { target c++17 } }
2 // { dg-options "-fconcepts" }
3 // { dg-additional-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-locations=no" }
4 // { dg-additional-options "-fconcepts-diagnostics-depth=3" }
13 concept has_member_pet = requires(T t) { t.pet(); };
16 concept has_default_pet = T::is_pettable;
19 concept pettable = has_member_pet<T> or has_default_pet<T>;
21 void pet(pettable auto t);
26 pet(lizard{}); // { dg-error "no matching function for call to 'pet\\\(lizard\\\)'" }
29 /* { dg-begin-multiline-output "" }
30 * there are 3 candidates
31 * candidate 1: 'template<class auto:1> requires pettable<auto:1> void pet(auto:1)'
32 * template argument deduction/substitution failed:
33 * constraints not satisfied
34 * In substitution of 'template<class auto:1> requires pettable<auto:1> void pet(auto:1) [with auto:1 = lizard]':
36 * required for the satisfaction of 'pettable<auto:1>' [with auto:1 = lizard]
37 * no operand of the disjunction is satisfied
38 * the operand 'has_member_pet<T>' is unsatisfied because
39 * required for the satisfaction of 'has_member_pet<T>' [with T = lizard]
40 * required for the satisfaction of 'pettable<auto:1>' [with auto:1 = lizard]
41 * in requirements with 'T t' [with T = lizard]
42 * the required expression 't.pet()' is invalid, because
43 * error: 'struct lizard' has no member named 'pet'
44 * the operand 'has_default_pet<T>' is unsatisfied because
45 * required for the satisfaction of 'has_default_pet<T>' [with T = lizard]
46 * required for the satisfaction of 'pettable<auto:1>' [with auto:1 = lizard]
47 * error: 'is_pettable' is not a member of 'lizard'
48 * candidate 2: 'void pet(dog)'
49 * no known conversion for argument 1 from 'lizard' to 'dog'
50 * candidate 3: 'void pet(cat)'
51 * no known conversion for argument 1 from 'lizard' to 'cat'
52 { dg-end-multiline-output "" } */