Ilya Biryukov | 28f048a | 2018-05-30 12:50:48 +0000 | [diff] [blame] | 1 | // 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. |
| 4 | // RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:42:1 %s -o - 2>&1 | FileCheck %s |
| 5 | template <class T> |
| 6 | auto 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 | |
| 14 | template <class T> |
| 15 | auto 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 | |
| 23 | template <class T> |
| 24 | auto 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 | |
| 32 | auto 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 | |
| 40 | int test() { |
| 41 | int complete_in_this_function; |
| 42 | // CHECK: COMPLETION: complete_in_this_function |
| 43 | } |