brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · c0fa0f5 Raw
62 lines · cpp
1// We run clang in completion mode to force skipping of function bodies and2// check if the function bodies were skipped by observing the warnings that3// clang produces.4// RUN: not %clang_cc1 -std=c++14 -fsyntax-only -code-completion-at=%s:60:1 %s -o - 2>&1 | FileCheck %s5template <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 parentheses11  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 parentheses20  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 parentheses29  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 parentheses37  return 1;38};39 40template <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 parentheses46  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 parentheses55  return 1;56}57 58int test() {59  int complete_in_this_function;60  // CHECK: COMPLETION: complete_in_this_function61}62