From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- clang/test/PCH/cxx-templates.cpp | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 clang/test/PCH/cxx-templates.cpp (limited to 'clang/test/PCH/cxx-templates.cpp') diff --git a/clang/test/PCH/cxx-templates.cpp b/clang/test/PCH/cxx-templates.cpp new file mode 100644 index 0000000..7ce2477 --- /dev/null +++ b/clang/test/PCH/cxx-templates.cpp @@ -0,0 +1,70 @@ +// Test this without pch. +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o - +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s + +// Test with pch. +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump -o - +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - | FileCheck %s + +// CHECK: define weak_odr void @_ZN2S4IiE1mEv +// CHECK: define linkonce_odr void @_ZN2S3IiE1mEv + +struct A { + typedef int type; + static void my_f(); + template + static T my_templf(T x) { return x; } +}; + +void test(const int (&a6)[17]) { + int x = templ_f(3); + + S::templ(); + S::partial(); + S::explicit_special(); + + Dep::Ty ty; + Dep a; + a.f(); + + S3 s3; + s3.m(); + + TS5 ts(0); + + S6::t2 b6 = a6; +} + +template struct S4; + +S7 s7_5; + +namespace ZeroLengthExplicitTemplateArgs { + template void f(X*); +} + +// This used to overwrite memory and crash. +namespace Test1 { + struct StringHasher { + template static inline unsigned createHash(const T*, unsigned) { + return 0; + } + }; + + struct CaseFoldingHash { + static inline char foldCase(char) { + return 0; + } + + static unsigned hash(const char* data, unsigned length) { + return StringHasher::createHash(data, length); + } + }; +} + +template< typename D > +Foo< D >& Foo< D >::operator=( const Foo& other ) +{ + return *this; +} -- cgit v1.2.3