1// RUN: %check_clang_tidy -std=c++17-or-later %s fuchsia-trailing-return %t
2
3int add_one(const int arg) { return arg; }
4
5auto get_add_one() -> int (*)(const int) {
6 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: a trailing return type is disallowed for this function declaration
7 // CHECK-NEXT: auto get_add_one() -> int (*)(const int) {
8 return add_one;
9}
10
11auto lambda = [](double x, double y) {return x + y;};
12
13auto lambda2 = [](double x, double y) -> double {return x + y;};
14
15int main() {
16 get_add_one()(5);
17 return 0;
18}
19
20template <typename T1, typename T2>
21auto fn(const T1 &lhs, const T2 &rhs) -> decltype(lhs + rhs) {
22 return lhs + rhs;
23}
24
25// Now check that implicit and explicit C++17 deduction guides don't trigger this warning (PR#47614).
26
27template <typename T>
28struct ImplicitDeductionGuides {
29 ImplicitDeductionGuides(const T &);
30};
31
32template <typename A, typename B>
33struct pair {
34 A first;
35 B second;
36};
37
38template <typename T>
39struct UserDefinedDeductionGuides {
40 UserDefinedDeductionGuides(T);
41 template <typename T1, typename T2>
42 UserDefinedDeductionGuides(T1, T2);
43};
44
45template <typename T1, typename T2>
46UserDefinedDeductionGuides(T1, T2) -> UserDefinedDeductionGuides<pair<T1, T2>>;
47
48void foo() {
49 ImplicitDeductionGuides X(42);
50 UserDefinedDeductionGuides s(1, "abc");
51}
52

source code of clang-tools-extra/test/clang-tidy/checkers/fuchsia/trailing-return.cpp