diff --git a/clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp b/clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp new file mode 100644 index 000000000000..a6e2e30dd59b --- /dev/null +++ b/clang/test/CodeGenCXX/2004-03-08-ReinterpretCastCopy.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +struct A { + virtual void Method() = 0; +}; + +struct B : public A { + virtual void Method() { } +}; + +typedef void (A::*fn_type_a)(void); +typedef void (B::*fn_type_b)(void); + +int main(int argc, char **argv) +{ + fn_type_a f = reinterpret_cast(&B::Method); + fn_type_b g = reinterpret_cast(f); + B b; + (b.*g)(); + return 0; +} diff --git a/clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp b/clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp new file mode 100644 index 000000000000..5d8c8b004b79 --- /dev/null +++ b/clang/test/CodeGenCXX/2004-03-09-UnmangledBuiltinMethods.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s + +// CHECK: _ZN11AccessFlags6strlenEv +struct AccessFlags { + void strlen(); +}; + +void AccessFlags::strlen() { } diff --git a/clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp b/clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp new file mode 100644 index 000000000000..01350c00b9bd --- /dev/null +++ b/clang/test/CodeGenCXX/2004-03-15-CleanupsAndGotos.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +// Testcase from Bug 291 + +struct X { + ~X(); +}; + +void foo() { + X v; + +TryAgain: + goto TryAgain; +} diff --git a/clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp b/clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp new file mode 100644 index 000000000000..97254c18a51a --- /dev/null +++ b/clang/test/CodeGenCXX/2004-06-08-LateTemplateInstantiation.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + + +template +struct normal_iterator { + int FIELD; +}; + +void foo(normal_iterator); +normal_iterator baz(); + +void bar() { + foo(baz()); +} + +void *bar2() { + return (void*)foo; +} diff --git a/clang/test/CodeGenCXX/2004-09-27-CompilerCrash.cpp b/clang/test/CodeGenCXX/2004-09-27-CompilerCrash.cpp new file mode 100644 index 000000000000..5e5af4ab6029 --- /dev/null +++ b/clang/test/CodeGenCXX/2004-09-27-CompilerCrash.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +struct Pass {} ; +template +Pass *callDefaultCtor() { return new PassName(); } + +void foo(Pass *(*C)()); + +#include + +bool foo(std::string &X) { + return X.empty(); +} diff --git a/clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp b/clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp new file mode 100644 index 000000000000..618894fd7248 --- /dev/null +++ b/clang/test/CodeGenCXX/2004-09-27-DidntEmitTemplate.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s + +// This is a testcase for LLVM PR445, which was a problem where the +// instantiation of callDefaultCtor was not being emitted correctly. + +// CHECK-NOT: declare{{.*}}callDefaultCtor +struct Pass {}; + +template +Pass *callDefaultCtor() { return new Pass(); } + +void foo(Pass *(*C)()); + +struct basic_string { + bool empty() const { return true; } +}; + + +bool foo2(basic_string &X) { + return X.empty(); +} +void baz() { foo(callDefaultCtor); } diff --git a/clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp b/clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp new file mode 100644 index 000000000000..ebcce7796e71 --- /dev/null +++ b/clang/test/CodeGenCXX/2004-11-27-ExceptionCleanupAssertion.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 %s -emit-llvm -o /dev/null + +// This is PR421 + +struct Strongbad { + Strongbad(const char *str ); + ~Strongbad(); + operator const char *() const; +}; + +void TheCheat () { + Strongbad foo(0); + Strongbad dirs[] = { Strongbad(0) + 1}; +} diff --git a/clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp b/clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp new file mode 100644 index 000000000000..3bfecd54b780 --- /dev/null +++ b/clang/test/CodeGenCXX/2004-11-27-FriendDefaultArgCrash.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm %s -o /dev/null + +// PR447 + +namespace nm { + struct str { + friend int foo(int arg = 0); + }; +} diff --git a/clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp b/clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp new file mode 100644 index 000000000000..875c412c6b48 --- /dev/null +++ b/clang/test/CodeGenCXX/2005-01-03-StaticInitializers.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s + +struct S { + int A[2]; +}; + +// CHECK-NOT: llvm.global_ctor +int XX = (int)(long)&(((struct S*)0)->A[1]);