xref: /llvm-project/clang/test/FixIt/fixit-constrained-structured-binding.cpp (revision 07008a8df57f8eb75e934a3a01ed0a4a76ae92ce)
1 // RUN: not %clang_cc1 -std=c++20 -fdiagnostics-parseable-fixits -x c++ %s 2> %t
2 // RUN: FileCheck %s < %t
3 
4 template<typename T>
5 concept UnaryC = true;
6 template<typename T, typename U>
7 concept BinaryC = true;
8 
9 struct S{ int i, j; };
10 S get_S();
11 
12 template<typename T>
13 T get_T();
14 
use()15 void use() {
16   UnaryC auto [a, b] = get_S();
17   // CHECK: error: decomposition declaration cannot be declared with constrained 'auto'
18   // CHECK: fix-it:{{.*}}:{16:3-16:10}:""
19   BinaryC<int> auto [c, d] = get_S();
20   // CHECK: error: decomposition declaration cannot be declared with constrained 'auto'
21   // CHECK: fix-it:{{.*}}:{19:3-19:16}:""
22 }
23 
24 template<typename T>
TemplUse()25 void TemplUse() {
26   UnaryC auto [a, b] = get_T<T>();
27   // CHECK: error: decomposition declaration cannot be declared with constrained 'auto'
28   // XCHECK: fix-it:{{.*}}:{26:3-26:10}:""
29   BinaryC<T> auto [c, d] = get_T<T>();
30   // CHECK: error: decomposition declaration cannot be declared with constrained 'auto'
31   // XCHECK: fix-it:{{.*}}:{29:3-29:14}:""
32 }
33 
34