diff options
Diffstat (limited to 'llvm/test/C++Frontend')
60 files changed, 988 insertions, 0 deletions
diff --git a/llvm/test/C++Frontend/.cvsignore b/llvm/test/C++Frontend/.cvsignore new file mode 100644 index 00000000000..7f2443f2f31 --- /dev/null +++ b/llvm/test/C++Frontend/.cvsignore @@ -0,0 +1,3 @@ +Output +*.log +*.sum diff --git a/llvm/test/C++Frontend/2003-08-20-ExceptionFail.cpp b/llvm/test/C++Frontend/2003-08-20-ExceptionFail.cpp new file mode 100644 index 00000000000..fd1c6ad4c2a --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-20-ExceptionFail.cpp @@ -0,0 +1,12 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +void foo(); + +void bar() { + struct local { + ~local() { foo(); } + } local_obj; + + foo(); +} + diff --git a/llvm/test/C++Frontend/2003-08-21-EmptyClass.cpp b/llvm/test/C++Frontend/2003-08-21-EmptyClass.cpp new file mode 100644 index 00000000000..2f90b3a1053 --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-21-EmptyClass.cpp @@ -0,0 +1,9 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +// This tests compilation of EMPTY_CLASS_EXPR's + +struct empty {}; + +void foo(empty) {} + +void bar() { foo(empty()); } diff --git a/llvm/test/C++Frontend/2003-08-24-Cleanup.cpp.tr b/llvm/test/C++Frontend/2003-08-24-Cleanup.cpp.tr new file mode 100644 index 00000000000..ab0d1a0d11c --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-24-Cleanup.cpp.tr @@ -0,0 +1,10 @@ +// RUN: %llvmgxx -xc++ %s -c -o - | llvm-dis | grep unwind + +struct S { ~S(); }; + +int mightthrow(); + +int test() { + S s; + mightthrow(); +} diff --git a/llvm/test/C++Frontend/2003-08-27-TypeNamespaces.cpp b/llvm/test/C++Frontend/2003-08-27-TypeNamespaces.cpp new file mode 100644 index 00000000000..cd7247e6085 --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-27-TypeNamespaces.cpp @@ -0,0 +1,16 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +namespace foo { + namespace bar { + struct X { X(); }; + + X::X() {} + } +} + + +namespace { + struct Y { Y(); }; + Y::Y() {} +} diff --git a/llvm/test/C++Frontend/2003-08-28-ForwardType.cpp b/llvm/test/C++Frontend/2003-08-28-ForwardType.cpp new file mode 100644 index 00000000000..49322957245 --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-28-ForwardType.cpp @@ -0,0 +1,21 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +// Default placement versions of operator new. +inline void* operator new(unsigned, void* __p) throw(); + + +template<typename _CharT> +struct stdio_filebuf +{ stdio_filebuf(); + +}; + +extern stdio_filebuf<char> buf_cout; + +void foo() { + // Create stream buffers for the standard streams and use + // those buffers without destroying and recreating the + // streams. + new (&buf_cout) stdio_filebuf<char>(); + +} diff --git a/llvm/test/C++Frontend/2003-08-28-SaveExprBug.cpp b/llvm/test/C++Frontend/2003-08-28-SaveExprBug.cpp new file mode 100644 index 00000000000..2be35d8d522 --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-28-SaveExprBug.cpp @@ -0,0 +1,24 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +char* eback(); + +template<typename foo> +struct basic_filebuf { + char *instancevar; + + void callee() { + instancevar += eback() != eback(); + } + + void caller(); +}; + + +template<typename _CharT> +void basic_filebuf<_CharT>::caller() { + callee(); +} + + +template class basic_filebuf<char>; diff --git a/llvm/test/C++Frontend/2003-08-29-ArgPassingBug.cpp.tr b/llvm/test/C++Frontend/2003-08-29-ArgPassingBug.cpp.tr new file mode 100644 index 00000000000..ddb0dcec8c4 --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-29-ArgPassingBug.cpp.tr @@ -0,0 +1,13 @@ + +// RUN: %llvmgcc -xc++ -c -o /dev/null %s 2>&1 | not grep WARNING + +struct iterator { + iterator(); + iterator(const iterator &I); +}; + +iterator foo(const iterator &I) { return I; } + +void test() { + foo(iterator()); +} diff --git a/llvm/test/C++Frontend/2003-08-31-StructLayout.cpp b/llvm/test/C++Frontend/2003-08-31-StructLayout.cpp new file mode 100644 index 00000000000..99d66826622 --- /dev/null +++ b/llvm/test/C++Frontend/2003-08-31-StructLayout.cpp @@ -0,0 +1,16 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +// There is a HOLE in the derived2 object due to not wanting to place the two +// baseclass instances at the same offset! + +struct baseclass {}; + +class derived1 : public baseclass { + void * NodePtr; +}; + +class derived2 : public baseclass { + derived1 current; +}; + +derived2 RI; diff --git a/llvm/test/C++Frontend/2003-09-22-CompositeExprValue.cpp b/llvm/test/C++Frontend/2003-09-22-CompositeExprValue.cpp new file mode 100644 index 00000000000..a8208adc512 --- /dev/null +++ b/llvm/test/C++Frontend/2003-09-22-CompositeExprValue.cpp @@ -0,0 +1,11 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +struct duration { + duration operator/=(int c) { + return *this; + } +}; + +void a000090() { + duration() /= 1; +} diff --git a/llvm/test/C++Frontend/2003-09-29-ArgumentNumberMismatch.cpp b/llvm/test/C++Frontend/2003-09-29-ArgumentNumberMismatch.cpp new file mode 100644 index 00000000000..4873123d124 --- /dev/null +++ b/llvm/test/C++Frontend/2003-09-29-ArgumentNumberMismatch.cpp @@ -0,0 +1,17 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +// Non-POD classes cannot be passed into a function by component, because their +// dtors must be run. Instead, pass them in by reference. The C++ front-end +// was mistakenly "thinking" that 'foo' took a structure by component. + +struct C { + int A, B; + ~C() {} +}; + +void foo(C b); + +void test(C *P) { + foo(*P); +} + diff --git a/llvm/test/C++Frontend/2003-09-30-CommaExprBug.cpp b/llvm/test/C++Frontend/2003-09-30-CommaExprBug.cpp new file mode 100644 index 00000000000..afe470cd11b --- /dev/null +++ b/llvm/test/C++Frontend/2003-09-30-CommaExprBug.cpp @@ -0,0 +1,10 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +class Empty {}; + +void foo(Empty E); + +void bar() { + foo(Empty()); +} + diff --git a/llvm/test/C++Frontend/2003-09-30-ForIncrementExprBug.cpp b/llvm/test/C++Frontend/2003-09-30-ForIncrementExprBug.cpp new file mode 100644 index 00000000000..40c9c87ae1e --- /dev/null +++ b/llvm/test/C++Frontend/2003-09-30-ForIncrementExprBug.cpp @@ -0,0 +1,10 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +struct C {}; + +C &foo(); + +void foox() { + for (; ; foo()); +} + diff --git a/llvm/test/C++Frontend/2003-09-30-ForIncrementExprBug2.cpp b/llvm/test/C++Frontend/2003-09-30-ForIncrementExprBug2.cpp new file mode 100644 index 00000000000..e07eb425d28 --- /dev/null +++ b/llvm/test/C++Frontend/2003-09-30-ForIncrementExprBug2.cpp @@ -0,0 +1,12 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +// Test with an opaque type + +struct C; + +C &foo(); + +void foox() { + for (; ; foo()); +} + diff --git a/llvm/test/C++Frontend/2003-09-30-NestedFunctionDecl.cpp b/llvm/test/C++Frontend/2003-09-30-NestedFunctionDecl.cpp new file mode 100644 index 00000000000..b1c54b89d59 --- /dev/null +++ b/llvm/test/C++Frontend/2003-09-30-NestedFunctionDecl.cpp @@ -0,0 +1,12 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +// The C++ front-end thinks the two foo's are different, the LLVM emitter +// thinks they are the same. The disconnect causes problems. + +void foo() { } + +void bar() { + void foo(); + + foo(); +} diff --git a/llvm/test/C++Frontend/2003-10-17-BoolBitfields.cpp b/llvm/test/C++Frontend/2003-10-17-BoolBitfields.cpp new file mode 100644 index 00000000000..547a367d34e --- /dev/null +++ b/llvm/test/C++Frontend/2003-10-17-BoolBitfields.cpp @@ -0,0 +1,11 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +struct test { + bool A : 1; + bool B : 1; +}; + +void foo(test *T) { + T->B = true; +} + diff --git a/llvm/test/C++Frontend/2003-10-21-InnerClass.cpp.tr b/llvm/test/C++Frontend/2003-10-21-InnerClass.cpp.tr new file mode 100644 index 00000000000..4f7b436c14f --- /dev/null +++ b/llvm/test/C++Frontend/2003-10-21-InnerClass.cpp.tr @@ -0,0 +1,12 @@ +// RUN: %llvmgcc -xc++ -S -o - %s | grep '"struct.X::Y"' +struct X { + + struct Y { + Y(); + }; + +}; + +X::Y::Y() { + +} diff --git a/llvm/test/C++Frontend/2003-10-27-VirtualBaseClassCrash.cpp b/llvm/test/C++Frontend/2003-10-27-VirtualBaseClassCrash.cpp new file mode 100644 index 00000000000..f9fc80ee940 --- /dev/null +++ b/llvm/test/C++Frontend/2003-10-27-VirtualBaseClassCrash.cpp @@ -0,0 +1,17 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +template<class T> +struct super { + int Y; + void foo(); +}; + +template <class T> +struct test : virtual super<int> {}; + +extern test<int> X; + +void foo() { + X.foo(); +} diff --git a/llvm/test/C++Frontend/2003-11-02-WeakLinkage.cpp.tr b/llvm/test/C++Frontend/2003-11-02-WeakLinkage.cpp.tr new file mode 100644 index 00000000000..1e324caf2d6 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-02-WeakLinkage.cpp.tr @@ -0,0 +1,13 @@ +// RUN: %llvmgcc -xc++ -S -o - %s | not grep weak +// XFAIL: llvmgcc4 + +template<class T> +void thefunc(); + +template<class T> +inline void thefunc() {} + +void test() { + thefunc<int>(); +} + diff --git a/llvm/test/C++Frontend/2003-11-04-ArrayConstructors.cpp b/llvm/test/C++Frontend/2003-11-04-ArrayConstructors.cpp new file mode 100644 index 00000000000..4df4f9b6727 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-04-ArrayConstructors.cpp @@ -0,0 +1,12 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +struct Foo { + Foo(int); + ~Foo(); +}; +void foo() { + struct { + Foo name; + } Int[] = { 1 }; +} diff --git a/llvm/test/C++Frontend/2003-11-04-CatchLabelName.cpp b/llvm/test/C++Frontend/2003-11-04-CatchLabelName.cpp new file mode 100644 index 00000000000..8acf88ddbaf --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-04-CatchLabelName.cpp @@ -0,0 +1,11 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +#include <string> + +void bar(); + +void test() { + try { + bar(); + } catch (std::string) {} +} diff --git a/llvm/test/C++Frontend/2003-11-08-ArrayAddress.cpp.tr b/llvm/test/C++Frontend/2003-11-08-ArrayAddress.cpp.tr new file mode 100644 index 00000000000..9ad1b8f82f7 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-08-ArrayAddress.cpp.tr @@ -0,0 +1,10 @@ +// RUN: %llvmgxx -xc++ %s -c -o - | llvm-dis | grep getelementptr + +struct foo { + int array[100]; + void *getAddr(unsigned i); +}; + +void *foo::getAddr(unsigned i) { + return &array[i]; +} diff --git a/llvm/test/C++Frontend/2003-11-09-ConstructorTypeSafety.cpp.tr b/llvm/test/C++Frontend/2003-11-09-ConstructorTypeSafety.cpp.tr new file mode 100644 index 00000000000..3596d68e5d0 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-09-ConstructorTypeSafety.cpp.tr @@ -0,0 +1,20 @@ +// The code generated for this testcase should be completely typesafe! +// RUN: %llvmgcc -xc++ -S -o - %s | llvm-as | opt -die | llvm-dis | not grep ' cast ' + +struct contained { + unsigned X; + contained(); +}; + +struct base { + unsigned A, B; +}; + +struct derived : public base { + contained _M_value_field; +}; + +int test() { + derived X; +} + diff --git a/llvm/test/C++Frontend/2003-11-18-EnumArray.cpp b/llvm/test/C++Frontend/2003-11-18-EnumArray.cpp new file mode 100644 index 00000000000..6eaf9d66f2d --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-18-EnumArray.cpp @@ -0,0 +1,14 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +enum TchkType { + tchkNum, tchkString, tchkSCN, tchkNone +}; + +struct Operator { + enum TchkType tchk[8]; +}; + +struct Operator opTab[] = { + {{tchkNum, tchkNum, tchkString} } +}; + diff --git a/llvm/test/C++Frontend/2003-11-18-MemberInitializationCasting.cpp.tr b/llvm/test/C++Frontend/2003-11-18-MemberInitializationCasting.cpp.tr new file mode 100644 index 00000000000..1d607a2ac95 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-18-MemberInitializationCasting.cpp.tr @@ -0,0 +1,13 @@ +// RUN: %llvmgcc -xc++ -S -o - %s | llvm-as | opt -die | llvm-dis | not grep ' cast ' + +struct A { + A() : i(0) {} + int getI() {return i;} + int i; +}; + +int f(int j) +{ + A a; + return j+a.getI(); +} diff --git a/llvm/test/C++Frontend/2003-11-18-PtrMemConstantInitializer.cpp b/llvm/test/C++Frontend/2003-11-18-PtrMemConstantInitializer.cpp new file mode 100644 index 00000000000..ae76a6c6379 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-18-PtrMemConstantInitializer.cpp @@ -0,0 +1,14 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +struct Gfx { + void opMoveSetShowText(); +}; + +struct Operator { + void (Gfx::*func)(); +}; + +Operator opTab[] = { + {&Gfx::opMoveSetShowText}, +}; + diff --git a/llvm/test/C++Frontend/2003-11-25-ReturningOpaqueByValue.cpp b/llvm/test/C++Frontend/2003-11-25-ReturningOpaqueByValue.cpp new file mode 100644 index 00000000000..83fe1b3e810 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-25-ReturningOpaqueByValue.cpp @@ -0,0 +1,12 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +#include <vector> +std::vector<int> my_method (); + +int +main () +{ + my_method (); + return 0; +} + diff --git a/llvm/test/C++Frontend/2003-11-27-MultipleInheritanceThunk.cpp b/llvm/test/C++Frontend/2003-11-27-MultipleInheritanceThunk.cpp new file mode 100644 index 00000000000..16026c34b51 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-27-MultipleInheritanceThunk.cpp @@ -0,0 +1,28 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +struct CallSite { + int X; + + CallSite(const CallSite &CS); +}; + +struct AliasAnalysis { + int TD; + + virtual int getModRefInfo(CallSite CS); +}; + + +struct Pass { + int X; + virtual int foo(); +}; + +struct AliasAnalysisCounter : public Pass, public AliasAnalysis { + int getModRefInfo(CallSite CS) { + return 0; + } +}; + +AliasAnalysisCounter AAC; diff --git a/llvm/test/C++Frontend/2003-11-29-DuplicatedCleanupTest.cpp b/llvm/test/C++Frontend/2003-11-29-DuplicatedCleanupTest.cpp new file mode 100644 index 00000000000..8131baafae7 --- /dev/null +++ b/llvm/test/C++Frontend/2003-11-29-DuplicatedCleanupTest.cpp @@ -0,0 +1,41 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + +void doesntThrow() throw(); +struct F { + ~F() { doesntThrow(); } +}; + +void atest() { + F A; +lab: + F B; + goto lab; +} + +void test(int val) { +label: { + F A; + F B; + if (val == 0) goto label; + if (val == 1) goto label; +} +} + +void test3(int val) { +label: { + F A; + F B; + if (val == 0) { doesntThrow(); goto label; } + if (val == 1) { doesntThrow(); goto label; } +} +} + +void test4(int val) { +label: { + F A; + F B; + if (val == 0) { F C; goto label; } + if (val == 1) { F D; goto label; } +} +} diff --git a/llvm/test/C++Frontend/2003-12-08-ArrayOfPtrToMemberFunc.cpp b/llvm/test/C++Frontend/2003-12-08-ArrayOfPtrToMemberFunc.cpp new file mode 100644 index 00000000000..d5122340225 --- /dev/null +++ b/llvm/test/C++Frontend/2003-12-08-ArrayOfPtrToMemberFunc.cpp @@ -0,0 +1,12 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +struct Evil { + void fun (); +}; +int foo(); +typedef void (Evil::*memfunptr) (); +static memfunptr jumpTable[] = { &Evil::fun }; + +void Evil::fun() { + (this->*jumpTable[foo()]) (); +} diff --git a/llvm/test/C++Frontend/2004-01-11-DynamicInitializedConstant.cpp.tr b/llvm/test/C++Frontend/2004-01-11-DynamicInitializedConstant.cpp.tr new file mode 100644 index 00000000000..03fead23f2f --- /dev/null +++ b/llvm/test/C++Frontend/2004-01-11-DynamicInitializedConstant.cpp.tr @@ -0,0 +1,6 @@ +// RUN: %llvmgcc -xc++ -S -o - %s | not grep ' constant ' + +extern int X; +const int Y = X; +const int* foo() { return &Y; } + diff --git a/llvm/test/C++Frontend/2004-03-08-ReinterpretCastCopy.cpp b/llvm/test/C++Frontend/2004-03-08-ReinterpretCastCopy.cpp new file mode 100644 index 00000000000..755d7c7621f --- /dev/null +++ b/llvm/test/C++Frontend/2004-03-08-ReinterpretCastCopy.cpp @@ -0,0 +1,21 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +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<fn_type_a>(&B::Method); + fn_type_b g = reinterpret_cast<fn_type_b>(f); + B b; + (b.*g)(); + return 0; +} diff --git a/llvm/test/C++Frontend/2004-03-09-UnmangledBuiltinMethods.cpp.tr b/llvm/test/C++Frontend/2004-03-09-UnmangledBuiltinMethods.cpp.tr new file mode 100644 index 00000000000..b019e0c0ef3 --- /dev/null +++ b/llvm/test/C++Frontend/2004-03-09-UnmangledBuiltinMethods.cpp.tr @@ -0,0 +1,8 @@ +// RUN: %llvmgcc -xc++ -c -o - %s | llvm-dis | grep _ZN11AccessFlags6strlenEv + +struct AccessFlags { + void strlen(); +}; + +void AccessFlags::strlen() { } + diff --git a/llvm/test/C++Frontend/2004-03-15-CleanupsAndGotos.cpp b/llvm/test/C++Frontend/2004-03-15-CleanupsAndGotos.cpp new file mode 100644 index 00000000000..9bc70c84ab4 --- /dev/null +++ b/llvm/test/C++Frontend/2004-03-15-CleanupsAndGotos.cpp @@ -0,0 +1,14 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + +// Testcase from Bug 291 + +struct X { + ~X(); +}; + +void foo() { + X v; + +TryAgain: + goto TryAgain; +} diff --git a/llvm/test/C++Frontend/2004-06-08-LateTemplateInstantiation.cpp b/llvm/test/C++Frontend/2004-06-08-LateTemplateInstantiation.cpp new file mode 100644 index 00000000000..16d8e5edf51 --- /dev/null +++ b/llvm/test/C++Frontend/2004-06-08-LateTemplateInstantiation.cpp @@ -0,0 +1,19 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + + +template<typename Ty> +struct normal_iterator { + int FIELD; +}; + +void foo(normal_iterator<int>); +normal_iterator<int> baz(); + +void bar() { + foo(baz()); +} + +void *bar2() { + return (void*)foo; +} diff --git a/llvm/test/C++Frontend/2004-09-27-CompilerCrash.cpp b/llvm/test/C++Frontend/2004-09-27-CompilerCrash.cpp new file mode 100644 index 00000000000..726bd86a40d --- /dev/null +++ b/llvm/test/C++Frontend/2004-09-27-CompilerCrash.cpp @@ -0,0 +1,19 @@ +// RUN: %llvmgxx -S %s -o - | llvm-as -f -o /dev/null + + + +struct Pass {} ; +template<typename PassName> +Pass *callDefaultCtor() { return new PassName(); } + +void foo(Pass *(*C)()); + +#include <bits/c++config.h> +#include <bits/stringfwd.h> +#include <bits/char_traits.h> +#include <memory> // For allocator. +#include <bits/basic_string.h> + +bool foo(std::string &X) { + return X.empty(); +} diff --git a/llvm/test/C++Frontend/2004-09-27-DidntEmitTemplate.cpp.tr b/llvm/test/C++Frontend/2004-09-27-DidntEmitTemplate.cpp.tr new file mode 100644 index 00000000000..21f4ac854fa --- /dev/null +++ b/llvm/test/C++Frontend/2004-09-27-DidntEmitTemplate.cpp.tr @@ -0,0 +1,22 @@ +// RUN: llvmgcc -xc++ %s -c -o - | llvm-dis | grep callDefaultCtor | not grep declare + +// This is a testcase for LLVM PR445, which was a problem where the +// instantiation of callDefaultCtor was not being emitted correctly. + +struct Pass {}; + +template<typename PassName> +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<Pass>); } + diff --git a/llvm/test/C++Frontend/2004-11-27-EmitsUnusedInlineFunctions.cpp b/llvm/test/C++Frontend/2004-11-27-EmitsUnusedInlineFunctions.cpp new file mode 100644 index 00000000000..68df84c0756 --- /dev/null +++ b/llvm/test/C++Frontend/2004-11-27-EmitsUnusedInlineFunctions.cpp @@ -0,0 +1,7 @@ +// The C++ front-end was emitting WAY too many inline functions. This test +// verifies that it does not emit the body of getchar, because it is not used. +// This corresponds to PR459 + +// RUN: %llvmgxx %s -S -o - | not grep '^int .getchar' + +#include <stdio.h> diff --git a/llvm/test/C++Frontend/2004-11-27-ExceptionCleanupAssertion.cpp b/llvm/test/C++Frontend/2004-11-27-ExceptionCleanupAssertion.cpp new file mode 100644 index 00000000000..f3d225e81a6 --- /dev/null +++ b/llvm/test/C++Frontend/2004-11-27-ExceptionCleanupAssertion.cpp @@ -0,0 +1,14 @@ +// RUN: %llvmgxx %s -S -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/llvm/test/C++Frontend/2004-11-27-FriendDefaultArgCrash.cpp b/llvm/test/C++Frontend/2004-11-27-FriendDefaultArgCrash.cpp new file mode 100644 index 00000000000..731e72617b9 --- /dev/null +++ b/llvm/test/C++Frontend/2004-11-27-FriendDefaultArgCrash.cpp @@ -0,0 +1,9 @@ +// RUN: %llvmgxx %s -o /dev/null -S + +// PR447 + +namespace nm { + struct str { + friend int foo(int arg = 0); + }; +} diff --git a/llvm/test/C++Frontend/2004-11-27-InlineAsmFunctionRedefinition.cpp b/llvm/test/C++Frontend/2004-11-27-InlineAsmFunctionRedefinition.cpp new file mode 100644 index 00000000000..42b223bc99c --- /dev/null +++ b/llvm/test/C++Frontend/2004-11-27-InlineAsmFunctionRedefinition.cpp @@ -0,0 +1,26 @@ +// RUN: %llvmgxx %s -S -o /dev/null + +// PR397 + +struct stat { }; +struct stat64 { }; + +extern "C" { + +extern int lstat(const char *, struct stat *) __asm__("lstat64"); +extern int lstat64(const char *, struct stat64 *); + +extern int __lxstat(int, const char *, struct stat *) __asm__("__lxstat64"); +extern int __lxstat64(int, const char *, struct stat64 *); + +extern __inline__ int lstat(const char *path, struct stat *statbuf) { + return __lxstat(3, path, statbuf); +} +extern __inline__ int lstat64(const char *path, struct stat64 *statbuf) { + return __lxstat64(3, path, statbuf); +} +} + +int do_one_file(void) { + return lstat(0, 0) + lstat64(0,0); +} diff --git a/llvm/test/C++Frontend/2005-01-03-StaticInitializers.cpp b/llvm/test/C++Frontend/2005-01-03-StaticInitializers.cpp new file mode 100644 index 00000000000..27da715c147 --- /dev/null +++ b/llvm/test/C++Frontend/2005-01-03-StaticInitializers.cpp @@ -0,0 +1,8 @@ +// RUN: %llvmgxx %s -S -o - | not grep 'llvm.global_ctor' + +struct S { + int A[2]; +}; + +int XX = (int)&(((struct S*)0)->A[1]); + diff --git a/llvm/test/C++Frontend/2005-02-11-AnonymousUnion.cpp b/llvm/test/C++Frontend/2005-02-11-AnonymousUnion.cpp new file mode 100644 index 00000000000..b0ff7e75075 --- /dev/null +++ b/llvm/test/C++Frontend/2005-02-11-AnonymousUnion.cpp @@ -0,0 +1,32 @@ +// RUN: %llvmgxx %s -S -o - + +// Test anonymous union with members of the same size. +int test1(float F) { + union { + float G; + int i; + }; + G = F; + return i; +} + +// test anonymous union with members of differing size. +int test2(short F) { + volatile union { + short G; + int i; + }; + G = F; + return i; +} + +// Make sure that normal unions work. duh :) +volatile union { + short S; + int i; +} U; + +int test3(short s) { + U.S = s; + return U.i; +} diff --git a/llvm/test/C++Frontend/2005-02-13-BadDynamicInit.cpp b/llvm/test/C++Frontend/2005-02-13-BadDynamicInit.cpp new file mode 100644 index 00000000000..84fa565f240 --- /dev/null +++ b/llvm/test/C++Frontend/2005-02-13-BadDynamicInit.cpp @@ -0,0 +1,9 @@ +// RUN: %llvmgxx %s -S -o - | not grep llvm.global_ctors +// This testcase corresponds to PR509 +struct Data { + unsigned *data; + unsigned array[1]; +}; + +Data shared_null = { shared_null.array }; + diff --git a/llvm/test/C++Frontend/2005-02-14-BitFieldOffset.cpp b/llvm/test/C++Frontend/2005-02-14-BitFieldOffset.cpp new file mode 100644 index 00000000000..375b0902a1c --- /dev/null +++ b/llvm/test/C++Frontend/2005-02-14-BitFieldOffset.cpp @@ -0,0 +1,11 @@ +// RUN: %llvmgxx %s -S -o - | not grep 'int 6' + +struct QVectorTypedData { + int size; + unsigned int sharable : 1; + unsigned short array[1]; +}; + +void foo(QVectorTypedData *X) { + X->array[0] = 123; +} diff --git a/llvm/test/C++Frontend/2005-02-19-BitfieldStructCrash.cpp b/llvm/test/C++Frontend/2005-02-19-BitfieldStructCrash.cpp new file mode 100644 index 00000000000..8f571e074b8 --- /dev/null +++ b/llvm/test/C++Frontend/2005-02-19-BitfieldStructCrash.cpp @@ -0,0 +1,14 @@ +// RUN: %llvmgxx -S %s -o - + +struct QChar {unsigned short X; QChar(unsigned short); } ; + +struct Command { + Command(QChar c) : c(c) {} + unsigned int type : 4; + QChar c; + }; + +Command X(QChar('c')); + +void Foo(QChar ); +void bar() { Foo(X.c); } diff --git a/llvm/test/C++Frontend/2005-02-19-UnnamedVirtualThunkArgument.cpp b/llvm/test/C++Frontend/2005-02-19-UnnamedVirtualThunkArgument.cpp new file mode 100644 index 00000000000..853fee7dcf3 --- /dev/null +++ b/llvm/test/C++Frontend/2005-02-19-UnnamedVirtualThunkArgument.cpp @@ -0,0 +1,22 @@ +// RUN: %llvmgxx -S %s -o /dev/null + +struct Foo { + Foo(); + virtual ~Foo(); +}; + +struct Bar { + Bar(); + virtual ~Bar(); + virtual bool test(bool) const; +}; + +struct Baz : public Foo, public Bar { + Baz(); + virtual ~Baz(); + virtual bool test(bool) const; +}; + +bool Baz::test(bool) const { + return true; +} diff --git a/llvm/test/C++Frontend/2005-02-20-BrokenReferenceTest.cpp b/llvm/test/C++Frontend/2005-02-20-BrokenReferenceTest.cpp new file mode 100644 index 00000000000..31026d30e90 --- /dev/null +++ b/llvm/test/C++Frontend/2005-02-20-BrokenReferenceTest.cpp @@ -0,0 +1,11 @@ +// RUN: %llvmgxx %s -S -o /dev/null + +void test(unsigned char *b, int rb) { + typedef unsigned char imgfoo[10][rb]; + imgfoo &br = *(imgfoo *)b; + + br[0][0] = 1; + + rb = br[0][0]; +} + diff --git a/llvm/test/C++Frontend/2005-02-27-PlacementArrayNewCrash.cpp b/llvm/test/C++Frontend/2005-02-27-PlacementArrayNewCrash.cpp new file mode 100644 index 00000000000..a8fc6685ac4 --- /dev/null +++ b/llvm/test/C++Frontend/2005-02-27-PlacementArrayNewCrash.cpp @@ -0,0 +1,8 @@ +// RUN: %llvmgxx -S %s -o - + +#include <new> +typedef double Ty[4]; + +void foo(Ty *XX) { + new(XX) Ty(); +} diff --git a/llvm/test/C++Frontend/2005-07-21-VirtualBaseAccess.cpp b/llvm/test/C++Frontend/2005-07-21-VirtualBaseAccess.cpp new file mode 100644 index 00000000000..7711cff6d36 --- /dev/null +++ b/llvm/test/C++Frontend/2005-07-21-VirtualBaseAccess.cpp @@ -0,0 +1,14 @@ +// RUN: %llvmgxx -xc++ %s -c -o - | opt -die | llvm-dis | not grep cast + +void foo(int*); + +struct FOO { + int X; +}; + +struct BAR : virtual FOO { BAR(); }; + +int testfn() { + BAR B; + foo(&B.X); +} diff --git a/llvm/test/C++Frontend/2006-03-01-GimplifyCrash.cpp b/llvm/test/C++Frontend/2006-03-01-GimplifyCrash.cpp new file mode 100644 index 00000000000..b0d00fe17dd --- /dev/null +++ b/llvm/test/C++Frontend/2006-03-01-GimplifyCrash.cpp @@ -0,0 +1,14 @@ +// RUN: %llvmgxx -S %s -o - + +struct PrefMapElem { + virtual ~PrefMapElem(); + unsigned int fPrefId; +}; + +int foo() { + PrefMapElem* fMap; + if (fMap[0].fPrefId == 1) + return 1; + + return 0; +} diff --git a/llvm/test/C++Frontend/2006-03-06-C++RecurseCrash.cpp b/llvm/test/C++Frontend/2006-03-06-C++RecurseCrash.cpp new file mode 100644 index 00000000000..2fb3fb7cdc2 --- /dev/null +++ b/llvm/test/C++Frontend/2006-03-06-C++RecurseCrash.cpp @@ -0,0 +1,24 @@ +// RUN: %llvmgcc %s -S -o - +namespace std { + class exception { }; + + class type_info { + public: + virtual ~type_info(); + }; + +} + +namespace __cxxabiv1 { + class __si_class_type_info : public std::type_info { + ~__si_class_type_info(); + }; +} + +class recursive_init: public std::exception { +public: + virtual ~recursive_init() throw (); +}; + +recursive_init::~recursive_init() throw() { } + diff --git a/llvm/test/C++Frontend/2006-09-08-powi.cpp b/llvm/test/C++Frontend/2006-09-08-powi.cpp new file mode 100644 index 00000000000..75cbfda7cbc --- /dev/null +++ b/llvm/test/C++Frontend/2006-09-08-powi.cpp @@ -0,0 +1,7 @@ +// RUN: %llvmgxx -O3 -S -o - %s + +#include <cmath> + +double foo(double X, int Y) { + return std::pow(X, Y); +} diff --git a/llvm/test/C++Frontend/2006-09-12-OpaqueStructCrash.cpp b/llvm/test/C++Frontend/2006-09-12-OpaqueStructCrash.cpp new file mode 100644 index 00000000000..f3160e84e2c --- /dev/null +++ b/llvm/test/C++Frontend/2006-09-12-OpaqueStructCrash.cpp @@ -0,0 +1,28 @@ +// RUN: %llvmgxx -O3 -S -o - %s + +struct A { + virtual ~A(); +}; + +template <typename Ty> +struct B : public A { + ~B () { delete [] val; } +private: + Ty* val; +}; + +template <typename Ty> +struct C : public A { + C (); + ~C (); +}; + +template <typename Ty> +struct D : public A { + D () {} + private: + B<C<Ty> > blocks; +}; + +template class D<double>; + diff --git a/llvm/test/C++Frontend/2006-09-27-Debug-Protection.cpp b/llvm/test/C++Frontend/2006-09-27-Debug-Protection.cpp new file mode 100644 index 00000000000..87bc0d595ad --- /dev/null +++ b/llvm/test/C++Frontend/2006-09-27-Debug-Protection.cpp @@ -0,0 +1,14 @@ +// XFAIL: llvmgcc3 +// RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'i32 1,' && +// RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'i32 2,' + +class A { +public: + int x; +protected: + int y; +private: + int z; +}; + +A a; diff --git a/llvm/test/C++Frontend/2006-10-30-ClassBitfield.cpp b/llvm/test/C++Frontend/2006-10-30-ClassBitfield.cpp new file mode 100644 index 00000000000..bd3b173cf8f --- /dev/null +++ b/llvm/test/C++Frontend/2006-10-30-ClassBitfield.cpp @@ -0,0 +1,16 @@ +// RUN: %llvmgxx %s -emit-llvm -S -o - +// PR954 + +struct _Refcount_Base { + unsigned long _M_ref_count; + int _M_ref_count_lock; + _Refcount_Base() : _M_ref_count(0) {} +}; + +struct _Rope_RopeRep : public _Refcount_Base +{ +public: + int _M_tag:8; +}; + +int foo(_Rope_RopeRep* r) { return r->_M_tag; } diff --git a/llvm/test/C++Frontend/2006-11-30-ConstantExprCrash.cpp b/llvm/test/C++Frontend/2006-11-30-ConstantExprCrash.cpp new file mode 100644 index 00000000000..365c8e80fbf --- /dev/null +++ b/llvm/test/C++Frontend/2006-11-30-ConstantExprCrash.cpp @@ -0,0 +1,27 @@ +// RUN: %llvmgxx %s -emit-llvm -S -o - +// PR1027 + +struct sys_var { + unsigned name_length; + + bool no_support_one_shot; + sys_var() {} +}; + + +struct sys_var_thd : public sys_var { +}; + +extern sys_var_thd sys_auto_is_null; + +sys_var *getsys_variables() { + return &sys_auto_is_null; +} + +sys_var *sys_variables = &sys_auto_is_null; + + + + + + diff --git a/llvm/test/C++Frontend/2007-01-06-ELF-Thunk-Sections.cpp b/llvm/test/C++Frontend/2007-01-06-ELF-Thunk-Sections.cpp new file mode 100644 index 00000000000..b1fb0dbd6b1 --- /dev/null +++ b/llvm/test/C++Frontend/2007-01-06-ELF-Thunk-Sections.cpp @@ -0,0 +1,50 @@ +// RUN: %llvmgxx %s -emit-llvm -S -o - && +// RUN: %llvmgxx %s -emit-llvm -S -o - | not grep 'gnu.linkonce.' +// PR1085 + +class +__attribute__((visibility("default"))) QGenericArgument +{ + public:inline QGenericArgument(const char *aName = 0, const void *aData = 0):_data(aData), _name(aName) { + } + private:const void *_data; + const char *_name; +}; +struct __attribute__ (( + visibility("default"))) QMetaObject +{ + struct { + } + d; +}; +class +__attribute__((visibility("default"))) QObject +{ + virtual const QMetaObject *metaObject() const; +}; +class +__attribute__((visibility("default"))) QPaintDevice +{ + public:enum PaintDeviceMetric { + PdmWidth = 1, PdmHeight, PdmWidthMM, PdmHeightMM, PdmNumColors, PdmDepth, PdmDpiX, PdmDpiY, PdmPhysicalDpiX, PdmPhysicalDpiY + }; + virtual ~ QPaintDevice(); + union { + } + ct; +}; +class +__attribute__((visibility("default"))) QWidget:public QObject, public QPaintDevice +{ +}; +class +__attribute__((visibility("default"))) QDialog:public QWidget +{ +}; +class TopicChooser:public QDialog { + virtual const QMetaObject *metaObject() const; +}; +const QMetaObject *TopicChooser:: +metaObject() const +{ +} diff --git a/llvm/test/C++Frontend/2007-01-06-PtrMethodInit.cpp b/llvm/test/C++Frontend/2007-01-06-PtrMethodInit.cpp new file mode 100644 index 00000000000..f87c8d888fc --- /dev/null +++ b/llvm/test/C++Frontend/2007-01-06-PtrMethodInit.cpp @@ -0,0 +1,75 @@ +// RUN: %llvmgxx %s -emit-llvm -S -o - +// PR1084 + +extern "C" +{ + typedef unsigned char PRUint8; + typedef unsigned int PRUint32; +} +typedef PRUint32 nsresult; +struct nsID +{ +}; +typedef nsID nsIID; +class nsISupports +{ +}; +extern "C++" +{ + template < class T > struct nsCOMTypeInfo + { + static const nsIID & GetIID () + { + } + }; +} + +class nsIDOMEvent:public nsISupports +{ +}; +class nsIDOMEventListener:public nsISupports +{ +public:static const nsIID & GetIID () + { + } + virtual nsresult + __attribute__ ((regparm (0), cdecl)) HandleEvent (nsIDOMEvent * event) = + 0; +}; +class nsIDOMMouseListener:public nsIDOMEventListener +{ +public:static const nsIID & GetIID () + { + static const nsIID iid = { + }; + } + virtual nsresult + __attribute__ ((regparm (0), + cdecl)) MouseDown (nsIDOMEvent * aMouseEvent) = 0; +}; +typedef +typeof (&nsIDOMEventListener::HandleEvent) + GenericHandler; + struct EventDispatchData + { + PRUint32 message; + GenericHandler method; + PRUint8 bits; + }; + struct EventTypeData + { + const EventDispatchData *events; + int numEvents; + const nsIID *iid; + }; + static const EventDispatchData sMouseEvents[] = { + { + (300 + 2), + reinterpret_cast < GenericHandler > (&nsIDOMMouseListener::MouseDown), + 0x01} + }; +static const EventTypeData sEventTypes[] = { + { + sMouseEvents, (sizeof (sMouseEvents) / sizeof (sMouseEvents[0])), + &nsCOMTypeInfo < nsIDOMMouseListener >::GetIID ()} +}; diff --git a/llvm/test/C++Frontend/dg.exp b/llvm/test/C++Frontend/dg.exp new file mode 100644 index 00000000000..142de8a6c8f --- /dev/null +++ b/llvm/test/C++Frontend/dg.exp @@ -0,0 +1,3 @@ +load_lib llvm-dg.exp + +llvm-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] $objdir $srcdir $subdir $target_triplet $llvmgcc $llvmgxx $prcontext $llvmgcc_version |