ipa-cp: Perform operations in the appropriate types (PR 118097)
[gcc.git] / gcc / testsuite / g++.dg / concepts / nested-diagnostics-1.C
blobe642676841d3e3899260c1d0eecbb0b9472fe3fb
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" }
6 struct dog {};
7 struct cat {};
9 void pet(dog);
10 void pet(cat);
12 template <class T>
13 concept has_member_pet = requires(T t) { t.pet(); };
15 template <class T>
16 concept has_default_pet = T::is_pettable;
18 template <class T>
19 concept pettable = has_member_pet<T> or has_default_pet<T>;
21 void pet(pettable auto t);
23 struct lizard {};
25 int main() {
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]':
35           * required from here
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 "" } */