xref: /minix3/external/bsd/llvm/dist/clang/test/PCH/cxx-chain-function-template.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -chain-include %s -chain-include %s -fsyntax-only %s
2*f4a2713aSLionel Sambuc // Just don't crash.
3*f4a2713aSLionel Sambuc #if !defined(RUN1)
4*f4a2713aSLionel Sambuc #define RUN1
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc struct CXXRecordDecl { CXXRecordDecl(int); };
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc template <typename T, typename U>
cast(U u)9*f4a2713aSLionel Sambuc T cast(U u) {
10*f4a2713aSLionel Sambuc   return reinterpret_cast<T&>(u);
11*f4a2713aSLionel Sambuc }
12*f4a2713aSLionel Sambuc 
test1()13*f4a2713aSLionel Sambuc void test1() {
14*f4a2713aSLionel Sambuc   cast<float>(1);
15*f4a2713aSLionel Sambuc }
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc #elif !defined(RUN2)
18*f4a2713aSLionel Sambuc #define RUN2
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc template <typename T>
test2(T)21*f4a2713aSLionel Sambuc void test2(T) {
22*f4a2713aSLionel Sambuc   cast<CXXRecordDecl>(1.0f);
23*f4a2713aSLionel Sambuc }
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc #else
26*f4a2713aSLionel Sambuc 
test3()27*f4a2713aSLionel Sambuc void test3() {
28*f4a2713aSLionel Sambuc   cast<CXXRecordDecl>(1.0f);
29*f4a2713aSLionel Sambuc   test2(1);
30*f4a2713aSLionel Sambuc }
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc #endif
33