blob: ab2465d7fb0491ac2fc4dec87e57db6a1449368f [file] [log] [blame]
Ilya Biryukov28f048a2018-05-30 12:50:48 +00001// We run clang in completion mode to force skipping of function bodies and
2// check if the function bodies were skipped by observing the warnings that
3// clang produces.
Ilya Biryukov82ebdd72018-06-01 09:49:53 +00004// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:60:1 %s -o - 2>&1 | FileCheck %s
Ilya Biryukov28f048a2018-05-30 12:50:48 +00005template <class T>
6auto not_skipped() {
7 int x;
8 if (x = 10) {}
9 // Check that this function is not skipped.
10 // CHECK: 8:9: warning: using the result of an assignment as a condition without parentheses
11 return 1;
12}
13
14template <class T>
15auto lambda_not_skipped = []() {
16 int x;
17 if (x = 10) {}
18 // Check that this function is not skipped.
19 // CHECK: 17:9: warning: using the result of an assignment as a condition without parentheses
20 return 1;
21}
22
23template <class T>
24auto skipped() -> T {
25 int x;
26 if (x = 10) {}
27 // Check that this function is skipped.
28 // CHECK-NOT: 26:9: warning: using the result of an assignment as a condition without parentheses
29 return 1;
30};
31
32auto lambda_skipped = []() -> int {
33 int x;
34 if (x = 10) {}
35 // This could potentially be skipped, but it isn't at the moment.
36 // CHECK: 34:9: warning: using the result of an assignment as a condition without parentheses
37 return 1;
38};
39
Ilya Biryukov82ebdd72018-06-01 09:49:53 +000040template <class T>
41decltype(auto)** not_skipped_ptr() {
42 int x;
43 if (x = 10) {}
44 // Check that this function is not skipped.
45 // CHECK: 43:9: warning: using the result of an assignment as a condition without parentheses
46 return T();
47}
48
49template <class T>
50decltype(auto) not_skipped_decltypeauto() {
51 int x;
52 if (x = 10) {}
53 // Check that this function is not skipped.
54 // CHECK: 52:9: warning: using the result of an assignment as a condition without parentheses
55 return 1;
56}
57
Ilya Biryukov28f048a2018-05-30 12:50:48 +000058int test() {
59 int complete_in_this_function;
60 // CHECK: COMPLETION: complete_in_this_function
61}