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