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