cxx1y-init-captures.cpp 546 B

12345678910111213141516171819202122232425262728
  1. // No PCH:
  2. // RUN: %clang_cc1 -pedantic -std=c++1y -include %s -verify %s
  3. //
  4. // With PCH:
  5. // RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t
  6. // RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
  7. #ifndef HEADER
  8. #define HEADER
  9. auto counter = [a(0)] () mutable { return a++; };
  10. int x = counter();
  11. template<typename T> void f(T t) {
  12. [t(t)] { int n = t; } ();
  13. }
  14. #else
  15. int y = counter();
  16. void g() {
  17. f(0); // ok
  18. // expected-error@15 {{lvalue of type 'const char *const'}}
  19. f("foo"); // expected-note {{here}}
  20. }
  21. #endif