1 // RUN: %check_clang_tidy -std=c++20 %s modernize-use-trailing-return-type %t
2 
3 namespace std {
4 template <typename T, typename U>
5 struct is_same { static constexpr auto value = false; };
6 
7 template <typename T>
8 struct is_same<T, T> { static constexpr auto value = true; };
9 
10 template <typename T>
11 concept floating_point = std::is_same<T, float>::value || std::is_same<T, double>::value || std::is_same<T, long double>::value;
12 }
13 
14 //
15 // Concepts
16 //
17 
18 std::floating_point auto con1();
19 // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
20 // CHECK-FIXES: {{^}}auto con1() -> std::floating_point auto;{{$}}
21 
con1()22 std::floating_point auto con1() { return 3.14f; }
23 // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
24 // CHECK-FIXES: {{^}}auto con1() -> std::floating_point auto { return 3.14f; }{{$}}
25 
26 namespace a {
27 template <typename T>
28 concept Concept = true;
29 
30 template <typename T, typename U>
31 concept BinaryConcept = true;
32 }
33 
34 a::Concept decltype(auto) con2();
35 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
36 // CHECK-FIXES: {{^}}auto con2() -> a::Concept decltype(auto);{{$}}
37 
38 a::BinaryConcept<int> decltype(auto) con3();
39 // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
40 // CHECK-FIXES: {{^}}auto con3() -> a::BinaryConcept<int> decltype(auto);{{$}}
41 
42 const std::floating_point auto* volatile con4();
43 // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
44 // CHECK-FIXES: {{^}}auto con4() -> const std::floating_point auto* volatile;{{$}}
45 
46 template <typename T>
47 int req1(T t) requires std::floating_point<T>;
48 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
49 // CHECK-FIXES: {{^}}auto req1(T t) -> int requires std::floating_point<T>;{{$}}
50 
51 template <typename T>
req2(T t)52 T req2(T t) requires requires { t + t; };
53   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
54   // CHECK-FIXES: {{^}}auto req2(T t) -> T requires requires { t + t; };{{$}}
55