diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaCXX/linkage.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaCXX/linkage.cpp')
-rw-r--r-- | clang/test/SemaCXX/linkage.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/linkage.cpp b/clang/test/SemaCXX/linkage.cpp new file mode 100644 index 0000000..6b73d59 --- /dev/null +++ b/clang/test/SemaCXX/linkage.cpp @@ -0,0 +1,96 @@ +// This is an IR generation test because the calculation of visibility +// during IR gen will cause linkage to be implicitly recomputed and +// compared against the earlier cached value. If we had a way of +// testing linkage directly in Sema, that would be better. + +// RUN: %clang_cc1 -Werror -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s + +// PR8926 +namespace test0 { + typedef struct { + void *foo() { return 0; } + } A; + + // CHECK: define linkonce_odr i8* @_ZN5test01A3fooEv( + + void test(A *a) { + a->foo(); + } +} + +namespace test1 { + typedef struct { + template <unsigned n> void *foo() { return 0; } + + void foo() { + foo<0>(); + } + } A; + + // CHECK: define linkonce_odr void @_ZN5test11A3fooEv( + // another at the end + + void test(A *a) { + a->foo(); + } +} + +namespace test2 { + typedef struct { + template <unsigned n> struct B { + void *foo() { return 0; } + }; + + void foo(B<0> *b) { + b->foo(); + } + } A; + + // CHECK: define linkonce_odr void @_ZN5test21A3fooEPNS0_1BILj0EEE( + + void test(A *a) { + a->foo(0); + } +} + +namespace test3 { + namespace { struct A {}; } + + // CHECK: define internal void @_ZN5test34testENS_12_GLOBAL__N_11AE( + void test(A a) {} + void force() { test(A()); } + + // CHECK: define void @test3( + extern "C" void test3(A a) {} +} + +namespace { + // CHECK: define void @test4( + extern "C" void test4(void) {} +} + +// PR9316: Ensure that even non-namespace-scope function declarations in +// a C declaration context respect that over the anonymous namespace. +extern "C" { + namespace { + struct X { + int f() { + extern int g(); + extern int a; + + // Test both for mangling in the code generation and warnings from use + // of internal, undefined names via -Werror. + // CHECK: call i32 @g( + // CHECK: load i32* @a, + return g() + a; + } + }; + } + // Force the above function to be emitted by codegen. + int test(X& x) { + return x.f(); + } +} + +// CHECK: define linkonce_odr i8* @_ZN5test21A1BILj0EE3fooEv( +// CHECK: define linkonce_odr i8* @_ZN5test11A3fooILj0EEEPvv( |