[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / PCH / cxx2a-template-lambdas.cpp
blobc11de0aa8481d7116558565fcaa08d8a6c9d2202
1 // RUN: %clang_cc1 -std=c++2a -emit-pch %s -o %t
2 // RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
4 // RUN: %clang_cc1 -std=c++2a -emit-pch -fpch-instantiate-templates %s -o %t
5 // RUN: %clang_cc1 -std=c++2a -include-pch %t -verify %s
7 // expected-no-diagnostics
9 #ifndef HEADER
10 #define HEADER
12 auto l1 = []<int I>() constexpr -> int {
13 return I;
16 auto l2 = []<auto I>() constexpr -> decltype(I) {
17 return I;
20 auto l3 = []<class T>(auto i) constexpr -> T {
21 return T(i);
24 auto l4 = []<template<class> class T, class U>(T<U>, auto i) constexpr -> U {
25 return U(i);
28 #else /*included pch*/
30 static_assert(l1.operator()<5>() == 5);
31 static_assert(l1.operator()<6>() == 6);
33 static_assert(l2.operator()<7>() == 7);
34 static_assert(l2.operator()<nullptr>() == nullptr);
36 static_assert(l3.operator()<int>(8.4) == 8);
37 static_assert(l3.operator()<int>(9.9) == 9);
39 template<typename T>
40 struct DummyTemplate { };
42 static_assert(l4(DummyTemplate<float>(), 12) == 12.0);
43 static_assert(l4(DummyTemplate<int>(), 19.8) == 19);
45 #endif // HEADER