xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/extern-inline.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang -target i386-unknown-unknown -S -emit-llvm -std=gnu89 -o - %s | FileCheck %s
2*f4a2713aSLionel Sambuc // RUN: %clang -target i386-unknown-unknown -S -emit-llvm -fgnu89-inline -o - %s | FileCheck %s
3*f4a2713aSLionel Sambuc // PR5253
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc // If an extern inline function is redefined, functions should call the
6*f4a2713aSLionel Sambuc // redefinition.
f(int a)7*f4a2713aSLionel Sambuc extern inline int f(int a) {return a;}
g(void)8*f4a2713aSLionel Sambuc int g(void) {return f(0);}
9*f4a2713aSLionel Sambuc // CHECK: call i32 @f
f(int b)10*f4a2713aSLionel Sambuc int f(int b) {return 1+b;}
11*f4a2713aSLionel Sambuc // CHECK: load i32* %{{.*}}
12*f4a2713aSLionel Sambuc // CHECK: add nsw i32 1, %{{.*}}
h(void)13*f4a2713aSLionel Sambuc int h(void) {return f(1);}
14*f4a2713aSLionel Sambuc // CHECK: call i32 @f
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc // It shouldn't matter if the function was redefined static.
f2(int a,int b)17*f4a2713aSLionel Sambuc extern inline int f2(int a, int b) {return a+b;}
g2(void)18*f4a2713aSLionel Sambuc int g2(void) {return f2(0,1);}
19*f4a2713aSLionel Sambuc // CHECK: call i32 @f2
f2(int a,int b)20*f4a2713aSLionel Sambuc static int f2(int a, int b) {return a*b;}
21*f4a2713aSLionel Sambuc // CHECK: load i32* %{{.*}}
22*f4a2713aSLionel Sambuc // CHECK: load i32* %{{.*}}
23*f4a2713aSLionel Sambuc // CHECK: mul nsw i32 %{{.*}}, %{{.*}}
h2(void)24*f4a2713aSLionel Sambuc int h2(void) {return f2(1,2);}
25*f4a2713aSLionel Sambuc // CHECK: call i32 @f2
26*f4a2713aSLionel Sambuc 
27