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