xref: /llvm-project/clang/test/Misc/diag-template-diffing-cxx26.cpp (revision ad190fcf15c1d0beea1ba93b4d250e15d2e944f4)
1 // RUN: %clang_cc1 -fsyntax-only %s -std=c++26                                                  -verify=expected,notree
2 // RUN: %clang_cc1 -fsyntax-only %s -std=c++26 -fno-elide-type                                  -verify=expected,notree
3 // RUN: %clang_cc1 -fsyntax-only %s -std=c++26                 -fdiagnostics-show-template-tree -verify=expected,tree
4 // RUN: %clang_cc1 -fsyntax-only %s -std=c++26 -fno-elide-type -fdiagnostics-show-template-tree -verify=expected,tree
5 
6 namespace GH93068 {
7   int n[2];
8 
9   template <auto> struct A {}; // #A
10 
11   namespace t1 {
12     // notree-error@#1 {{no viable conversion from 'A<0>' to 'A<n + 1>'}}
13 
14     /* tree-error@#1 {{no viable conversion
15   A<
16     [0 != n + 1]>}}*/
17 
18     A<n + 1> v1 = A<0>(); // #1
19     // expected-note@#A {{no known conversion from 'A<0>' to 'const A<&n[1]> &' for 1st argument}}
20     // expected-note@#A {{no known conversion from 'A<0>' to 'A<&n[1]> &&' for 1st argument}}
21 
22     // notree-error@#2 {{no viable conversion from 'A<n>' to 'A<n + 1>'}}
23     /* tree-error@#2 {{no viable conversion
24   A<
25     [n != n + 1]>}}*/
26 
27     A<n + 1> v2 = A<n>(); // #2
28     // expected-note@#A {{no known conversion from 'A<n>' to 'const A<&n[1]> &' for 1st argument}}
29     // expected-note@#A {{no known conversion from 'A<n>' to 'A<&n[1]> &&' for 1st argument}}
30   } // namespace t1
31 
32   namespace t2 {
33     A<n> v1;
34     A<n + 1> v2;
35 
36     // notree-note@#A {{no known conversion from 'A<n>' to 'const A<(no argument)>' for 1st argument}}
37     // notree-note@#A {{no known conversion from 'A<n>' to 'A<(no argument)>' for 1st argument}}
38 
39     /* tree-note@#A {{no known conversion from argument type to parameter type for 1st argument
40   [(no qualifiers) != const] A<
41     [n != (no argument)]>}}*/
42 
43     /* tree-note@#A {{no known conversion from argument type to parameter type for 1st argument
44   A<
45     [n != (no argument)]>}}*/
46 
f()47     void f() { v2 = v1; } // expected-error {{no viable overloaded '='}}
48   } // namespace t2
49 } // namespace GH93068
50