xref: /llvm-project/clang/test/Modules/lambda-context.cpp (revision 0bae624934ccee9434893025fc80cfd4bbd8eec8)
1*0bae6249SRichard Smith // RUN: %clang_cc1 -fmodules -std=c++11 -emit-pch -o %t %s
2*0bae6249SRichard Smith // RUN: %clang_cc1 -fmodules -std=c++11 -include-pch %t %s -verify
3*0bae6249SRichard Smith //
4*0bae6249SRichard Smith // This test checks for a bug in the deserialization code that was only
5*0bae6249SRichard Smith // reachable with modules enabled, but actually building and using modules is
6*0bae6249SRichard Smith // not necessary in order to trigger it, so we just use PCH here to make the
7*0bae6249SRichard Smith // test simpler.
8*0bae6249SRichard Smith 
9*0bae6249SRichard Smith #ifndef HEADER_INCLUDED
10*0bae6249SRichard Smith #define HEADER_INCLUDED
11*0bae6249SRichard Smith 
XX12*0bae6249SRichard Smith struct X { template <typename T> X(T) {} };
__anon839dafd10102Y13*0bae6249SRichard Smith struct Y { Y(X x = [] {}); };
14*0bae6249SRichard Smith 
15*0bae6249SRichard Smith #else
16*0bae6249SRichard Smith 
17*0bae6249SRichard Smith // This triggers us to load the specialization of X::X for Y's lambda. That
18*0bae6249SRichard Smith // lambda's context decl must not be loaded as a result of loading the lambda,
19*0bae6249SRichard Smith // as that would hit a deserialization cycle.
__anon839dafd10202null20*0bae6249SRichard Smith X x = [] {}; // expected-no-diagnostics
21*0bae6249SRichard Smith 
22*0bae6249SRichard Smith #endif
23