1 // RUN: %clang_cc1 %s -triple i386-unknown-unknown -Wno-strict-prototypes -emit-llvm -o - -verify | FileCheck %s
2
3 int g();
4
foo(int i)5 int foo(int i) {
6 return g(i);
7 }
8
g(int i)9 int g(int i) {
10 return g(i);
11 }
12
13 typedef void T(void);
test3(T f)14 void test3(T f) {
15 f();
16 }
17
f0(void)18 void f0(void) {}
19 // CHECK-LABEL: define{{.*}} void @f0()
20
21 void f1();
f2(void)22 void f2(void) {
23 // CHECK: call void @f1()
24 f1(1, 2, 3);
25 }
26 // CHECK-LABEL: define{{.*}} void @f1()
f1()27 void f1() {}
28
29 // CHECK: define {{.*}} @f3{{\(\)|\(.*sret.*\)}}
f3(void)30 struct foo { int X, Y, Z; } f3(void) {
31 while (1) {}
32 }
33
34 // PR4423 - This shouldn't crash in codegen
f4()35 void f4() {}
f5(void)36 void f5(void) { f4(42); } //expected-warning {{too many arguments}}
37
38 // Qualifiers on parameter types shouldn't make a difference.
f6(const float f,const float g)39 static void f6(const float f, const float g) {
40 }
f7(float f,float g)41 void f7(float f, float g) {
42 f6(f, g);
43 // CHECK: define{{.*}} void @f7(float{{.*}}, float{{.*}})
44 // CHECK: call void @f6(float{{.*}}, float{{.*}})
45 }
46
47 // PR6911 - incomplete function types
48 struct Incomplete;
49 void f8_callback(struct Incomplete);
50 void f8_user(void (*callback)(struct Incomplete));
f8_test(void)51 void f8_test(void) {
52 f8_user(&f8_callback);
53 // CHECK-LABEL: define{{.*}} void @f8_test()
54 // CHECK: call void @f8_user(ptr noundef @f8_callback)
55 // CHECK: declare void @f8_user(ptr noundef)
56 // CHECK: declare void @f8_callback()
57 }
58
59 // PR10204: don't crash
test9_helper(void)60 static void test9_helper(void) {}
test9(void)61 void test9(void) {
62 (void) test9_helper;
63 }
64
65 // PR88917: don't crash
66 int b();
67
main()68 int main() {
69 return b(b);
70 // CHECK: call i32 @b(ptr noundef @b)
71 }
b(int (* f)())72 int b(int (*f)()){
73 return 0;
74 }
75 // CHECK-LABEL: define{{.*}} i32 @b(ptr noundef %f)
76