diff options
Diffstat (limited to 'test/FrontendC++')
-rw-r--r-- | test/FrontendC++/2010-05-10-Var-DbgInfo.cpp | 43 | ||||
-rw-r--r-- | test/FrontendC++/2010-05-11-alwaysinlineinstantiation.cpp | 31 | ||||
-rw-r--r-- | test/FrontendC++/2010-05-12-PtrToMember-Dbg.cpp | 17 | ||||
-rw-r--r-- | test/FrontendC++/thunk-weak-odr.cpp | 33 |
4 files changed, 124 insertions, 0 deletions
diff --git a/test/FrontendC++/2010-05-10-Var-DbgInfo.cpp b/test/FrontendC++/2010-05-10-Var-DbgInfo.cpp new file mode 100644 index 0000000..e6165c0 --- /dev/null +++ b/test/FrontendC++/2010-05-10-Var-DbgInfo.cpp @@ -0,0 +1,43 @@ +// RUN: %llvmgcc -S -O0 -g %s -o /dev/null +// PR 7104 + +struct A { + int Ai; +}; + +struct B : public A {}; +struct C : public B {}; + +const char * f(int C::*){ return ""; } +int f(int B::*) { return 1; } + +struct D : public C {}; + +const char * g(int B::*){ return ""; } +int g(int D::*) { return 1; } + +void test() +{ + int i = f(&A::Ai); + + const char * str = g(&A::Ai); +} + +// conversion of B::* to C::* is better than conversion of A::* to C::* +typedef void (A::*pmfa)(); +typedef void (B::*pmfb)(); +typedef void (C::*pmfc)(); + +struct X { + operator pmfa(); + operator pmfb(); +}; + + +void g(pmfc); + +void test2(X x) +{ + g(x); +} + diff --git a/test/FrontendC++/2010-05-11-alwaysinlineinstantiation.cpp b/test/FrontendC++/2010-05-11-alwaysinlineinstantiation.cpp new file mode 100644 index 0000000..203b542 --- /dev/null +++ b/test/FrontendC++/2010-05-11-alwaysinlineinstantiation.cpp @@ -0,0 +1,31 @@ +// RUN: %llvmgxx -xc++ %s -c -o - | llvm-dis | not grep ZN12basic_stringIcEC1Ev +// RUN: %llvmgxx -xc++ %s -c -o - | llvm-dis | grep ZN12basic_stringIcED1Ev | count 2 + +template<class charT> +class basic_string +{ +public: + basic_string(); + ~basic_string(); +}; + +template <class charT> +__attribute__ ((__visibility__("hidden"), __always_inline__)) inline +basic_string<charT>::basic_string() +{ +} + +template <class charT> +inline +basic_string<charT>::~basic_string() +{ +} + +typedef basic_string<char> string; + +extern template class basic_string<char>; + +int main() +{ + string s; +} diff --git a/test/FrontendC++/2010-05-12-PtrToMember-Dbg.cpp b/test/FrontendC++/2010-05-12-PtrToMember-Dbg.cpp new file mode 100644 index 0000000..66acfbe --- /dev/null +++ b/test/FrontendC++/2010-05-12-PtrToMember-Dbg.cpp @@ -0,0 +1,17 @@ +//RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep DW_TAG_auto_variable +class Foo +{ + public: + int x; + int y; + Foo (int i, int j) { x = i; y = j; } +}; + + +Foo foo(10, 11); + +int main() { + int Foo::* pmi = &Foo::y; + return foo.*pmi; +} + diff --git a/test/FrontendC++/thunk-weak-odr.cpp b/test/FrontendC++/thunk-weak-odr.cpp new file mode 100644 index 0000000..1d9d4dd --- /dev/null +++ b/test/FrontendC++/thunk-weak-odr.cpp @@ -0,0 +1,33 @@ +// RUN: %llvmgxx %s -S -o - | FileCheck %s +// <rdar://problem/7929157> + +struct A { + virtual int f() { return 1; } +}; + +struct B { + virtual int f() { return 2; } +}; + +struct C : A, B { + virtual int f() { return 3; } +}; + +struct D : C { + virtual int f() { return 4; } +}; + +static int f(D* d) { + B* b = d; + return b->f(); +}; + +int g() { + D d; + return f(&d); +} + +// Thunks should be marked as "weak ODR", not just "weak". +// +// CHECK: define weak_odr i32 @_ZThn{{[48]}}_N1C1fEv +// CHECK: define weak_odr i32 @_ZThn{{[48]}}_N1D1fEv |