128f048afSIlya Biryukov // We run clang in completion mode to force skipping of function bodies and
228f048afSIlya Biryukov // check if the function bodies were skipped by observing the warnings that
328f048afSIlya Biryukov // clang produces.
4*db64e7e9SNemanja Ivanovic // RUN: not %clang_cc1 -std=c++14 -fsyntax-only -code-completion-at=%s:60:1 %s -o - 2>&1 | FileCheck %s
528f048afSIlya Biryukov template <class T>
not_skipped()628f048afSIlya Biryukov auto not_skipped() {
728f048afSIlya Biryukov   int x;
828f048afSIlya Biryukov   if (x = 10) {}
928f048afSIlya Biryukov   // Check that this function is not skipped.
1028f048afSIlya Biryukov   // CHECK: 8:9: warning: using the result of an assignment as a condition without parentheses
1128f048afSIlya Biryukov   return 1;
1228f048afSIlya Biryukov }
1328f048afSIlya Biryukov 
1428f048afSIlya Biryukov template <class T>
__anon838e9ec00102() 1528f048afSIlya Biryukov auto lambda_not_skipped = []() {
1628f048afSIlya Biryukov   int x;
1728f048afSIlya Biryukov   if (x = 10) {}
1828f048afSIlya Biryukov   // Check that this function is not skipped.
1928f048afSIlya Biryukov   // CHECK: 17:9: warning: using the result of an assignment as a condition without parentheses
2028f048afSIlya Biryukov   return 1;
2128f048afSIlya Biryukov }
2228f048afSIlya Biryukov 
2328f048afSIlya Biryukov template <class T>
__anon838e9ec00202() 2428f048afSIlya Biryukov auto skipped() -> T {
2528f048afSIlya Biryukov   int x;
2628f048afSIlya Biryukov   if (x = 10) {}
2728f048afSIlya Biryukov   // Check that this function is skipped.
2828f048afSIlya Biryukov   // CHECK-NOT: 26:9: warning: using the result of an assignment as a condition without parentheses
2928f048afSIlya Biryukov   return 1;
3028f048afSIlya Biryukov };
3128f048afSIlya Biryukov 
__anon838e9ec00302() 3228f048afSIlya Biryukov auto lambda_skipped = []() -> int {
3328f048afSIlya Biryukov   int x;
3428f048afSIlya Biryukov   if (x = 10) {}
3528f048afSIlya Biryukov   // This could potentially be skipped, but it isn't at the moment.
3628f048afSIlya Biryukov   // CHECK: 34:9: warning: using the result of an assignment as a condition without parentheses
3728f048afSIlya Biryukov   return 1;
3828f048afSIlya Biryukov };
3928f048afSIlya Biryukov 
4082ebdd79SIlya Biryukov template <class T>
not_skipped_ptr()4182ebdd79SIlya Biryukov decltype(auto)** not_skipped_ptr() {
4282ebdd79SIlya Biryukov   int x;
4382ebdd79SIlya Biryukov   if (x = 10) {}
4482ebdd79SIlya Biryukov   // Check that this function is not skipped.
4582ebdd79SIlya Biryukov   // CHECK: 43:9: warning: using the result of an assignment as a condition without parentheses
4682ebdd79SIlya Biryukov   return T();
4782ebdd79SIlya Biryukov }
4882ebdd79SIlya Biryukov 
4982ebdd79SIlya Biryukov template <class T>
not_skipped_decltypeauto()5082ebdd79SIlya Biryukov decltype(auto) not_skipped_decltypeauto() {
5182ebdd79SIlya Biryukov   int x;
5282ebdd79SIlya Biryukov   if (x = 10) {}
5382ebdd79SIlya Biryukov   // Check that this function is not skipped.
5482ebdd79SIlya Biryukov   // CHECK: 52:9: warning: using the result of an assignment as a condition without parentheses
5582ebdd79SIlya Biryukov   return 1;
5682ebdd79SIlya Biryukov }
5782ebdd79SIlya Biryukov 
test()5828f048afSIlya Biryukov int test() {
5928f048afSIlya Biryukov   int complete_in_this_function;
6028f048afSIlya Biryukov   // CHECK: COMPLETION: complete_in_this_function
6128f048afSIlya Biryukov }
62