xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/pragma-weak.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc #pragma weak zex
4f4a2713aSLionel Sambuc int zex;
5f4a2713aSLionel Sambuc // GCC produces a weak symbol for this because it matches mangled names.
6f4a2713aSLionel Sambuc // Different c++ ABIs may or may not mangle this, so we produce a strong
7f4a2713aSLionel Sambuc // symbol.
8f4a2713aSLionel Sambuc // CHECK: @zex = global i32
9f4a2713aSLionel Sambuc 
10f4a2713aSLionel Sambuc #pragma weak foo
11f4a2713aSLionel Sambuc struct S {  void foo(); };
foo()12f4a2713aSLionel Sambuc void S::foo() {}
13*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define {{.*}}void @_ZN1S3fooEv(
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc #pragma weak zed
zed()16f4a2713aSLionel Sambuc namespace bar {  void zed() {} }
17f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_ZN3bar3zedEv(
18f4a2713aSLionel Sambuc 
19f4a2713aSLionel Sambuc #pragma weak bah
bah()20f4a2713aSLionel Sambuc void bah() {}
21f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z3bahv(
22f4a2713aSLionel Sambuc 
23f4a2713aSLionel Sambuc #pragma weak baz
baz()24f4a2713aSLionel Sambuc extern "C" void baz() {}
25f4a2713aSLionel Sambuc // CHECK-LABEL: define weak void @baz(
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc #pragma weak _Z3baxv
bax()28f4a2713aSLionel Sambuc void bax() {}
29f4a2713aSLionel Sambuc // GCC produces a weak symbol for this one, but it doesn't look like a good
30f4a2713aSLionel Sambuc // idea to expose the mangling to the pragma unless we really have to.
31f4a2713aSLionel Sambuc // CHECK-LABEL: define void @_Z3baxv(
32