llvm-project/clang/test/PCH/cxx1y-init-captures.cpp
Ilya Biryukov 629170fe45 [Sema] Lambdas are not part of immediate context for deduction
This commit implements [temp.deduct]p9.
Test updates include:
- New notes in `cxx1y-init-captures.cpp`, `lambda-expressions.cpp`
  and 'warn-unused-lambda-capture.cpp'.
  This seems to be caused by diagnosing errors earlier (during
  deduction) that were previously surfaced later (during
  instantiation).
- New error `lambda-unevaluated.cpp` is in line with [temp.deduct]p9.

Reviewed By: erichkeane, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D148802
2023-05-09 12:06:33 +02:00

33 lines
754 B
C++

// No PCH:
// RUN: %clang_cc1 -pedantic -std=c++1y -include %s -verify %s
//
// With PCH:
// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch -fpch-instantiate-templates %s -o %t
// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
#ifndef HEADER
#define HEADER
auto counter = [a(0)] () mutable { return a++; };
int x = counter();
template<typename T> void f(T t) {
[t(t)] { int n = t; } ();
}
#else
int y = counter();
void g() {
f(0); // ok
// expected-error@18 {{lvalue of type 'const char *const'}}
// expected-note@18 {{substituting into a lambda}}
f("foo"); // expected-note {{here}}
}
#endif