1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s 2 namespace foo { 3 4 // CHECK-NOT: @a = global 5 extern "C" int a; 6 7 // CHECK-NOT: @_ZN3foo1bE = global 8 extern int b; 9 10 // CHECK: @_ZN3foo1cE = global 11 int c = 5; 12 13 // CHECK-NOT: @_ZN3foo1dE 14 extern "C" struct d; 15 16 // CHECK-NOT: should_not_appear 17 extern "C++" int should_not_appear; 18 19 } 20 21 namespace test1 { 22 namespace { 23 struct X {}; 24 } 25 extern "C" { 26 // CHECK: @test1_b = global 27 X test1_b = X(); 28 } 29 void *use = &test1_b; 30 // CHECK: @_ZN5test13useE = global 31 } 32 33 namespace test2 { 34 namespace { 35 struct X {}; 36 } 37 38 // CHECK: @test2_b = global 39 extern "C" X test2_b; 40 X test2_b; 41 } 42 43 extern "C" { 44 static int unused_var; 45 static int unused_fn() { return 0; } 46 47 __attribute__((used)) static int internal_var; 48 __attribute__((used)) static int internal_fn() { return 0; } 49 50 __attribute__((used)) static int duplicate_internal_var; 51 __attribute__((used)) static int duplicate_internal_fn() { return 0; } 52 53 namespace N { 54 __attribute__((used)) static int duplicate_internal_var; 55 __attribute__((used)) static int duplicate_internal_fn() { return 0; } 56 } 57 58 // CHECK: @llvm.used = appending global {{.*}} @internal_var {{.*}} @internal_fn 59 60 // CHECK-NOT: @unused 61 // CHECK-NOT: @duplicate_internal 62 // CHECK: @internal_var = internal alias i32, i32* @_Z12internal_var 63 // CHECK-NOT: @unused 64 // CHECK-NOT: @duplicate_internal 65 // CHECK: @internal_fn = internal alias i32 (), i32 ()* @_Z11internal_fnv 66 // CHECK-NOT: @unused 67 // CHECK-NOT: @duplicate_internal 68 } 69 70 namespace PR19411 { 71 struct A { void f(); }; 72 extern "C" void A::f() { void g(); g(); } 73 // CHECK-LABEL: @_ZN7PR194111A1fEv( 74 // CHECK: call {{.*}}void @g() 75 } 76