1 // This is an IR generation test because the calculation of visibility
2 // during IR gen will cause linkage to be implicitly recomputed and
3 // compared against the earlier cached value. If we had a way of
4 // testing linkage directly in Sema, that would be better.
6 // RUN: %clang_cc1 -Werror -Wno-non-c-typedef-for-linkage -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
8 // CHECK: @_ZZN5test61A3fooEvE3bar = linkonce_odr global i32 0, align 4
13 void *foo() { return 0; }
16 // CHECK: define linkonce_odr noundef ptr @_ZN5test01A3fooEv(
25 template <unsigned n
> void *foo() { return 0; }
32 // CHECK: define linkonce_odr void @_ZN5test11A3fooEv(
42 template <unsigned n
> struct B
{
43 void *foo() { return 0; }
51 // CHECK: define linkonce_odr void @_ZN5test21A3fooEPNS0_1BILj0EEE(
59 namespace { struct A
{}; }
61 // CHECK: define internal void @_ZN5test34testENS_12_GLOBAL__N_11AE(
63 void force() { test(A()); }
65 // CHECK: define{{.*}} void @test3(
66 extern "C" void test3(A a
) {}
70 // CHECK: define{{.*}} void @test4(
71 extern "C" void test4(void) {}
74 // PR9316: Ensure that even non-namespace-scope function declarations in
75 // a C declaration context respect that over the anonymous namespace.
83 // Test both for mangling in the code generation and warnings from use
84 // of internal, undefined names via -Werror.
85 // CHECK: call i32 @g(
86 // CHECK: load i32, ptr @a,
91 // Force the above function to be emitted by codegen.
97 // CHECK: define linkonce_odr noundef ptr @_ZN5test11A3fooILj0EEEPvv(
98 // CHECK: define linkonce_odr noundef ptr @_ZN5test21A1BILj0EE3fooEv(
109 // Test that we don't compute linkage too hastily before we're done
110 // processing a record decl.
114 // Tested at top of file.