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