blob: 28e4bd0c8296df582cd8d166c55e5e85ba907777 [file] [log] [blame]
John McCall01f151e2011-09-21 08:08:30 +00001// RUN: %clang_cc1 %s -triple i386-unknown-unknown -emit-llvm -o - -verify | FileCheck %s
Daniel Dunbard5d31802009-02-19 07:15:39 +00002
Chris Lattner58c3f9e2007-12-02 06:27:33 +00003int g();
4
5int foo(int i) {
Mike Stump1eb44332009-09-09 15:08:12 +00006 return g(i);
Chris Lattner58c3f9e2007-12-02 06:27:33 +00007}
8
9int g(int i) {
Mike Stump1eb44332009-09-09 15:08:12 +000010 return g(i);
Chris Lattner58c3f9e2007-12-02 06:27:33 +000011}
12
Chris Lattner05d2fb42008-07-31 04:58:58 +000013// rdar://6110827
14typedef void T(void);
15void test3(T f) {
16 f();
17}
18
Douglas Gregor450da982009-02-16 20:58:07 +000019int a(int);
20int a() {return 1;}
Daniel Dunbard5d31802009-02-19 07:15:39 +000021
Daniel Dunbard5d31802009-02-19 07:15:39 +000022void f0() {}
John McCallb7d35892010-02-24 07:33:39 +000023// CHECK: define void @f0()
Daniel Dunbard5d31802009-02-19 07:15:39 +000024
25void f1();
Daniel Dunbard5d31802009-02-19 07:15:39 +000026void f2(void) {
John McCall01f151e2011-09-21 08:08:30 +000027// CHECK: call void bitcast (void ()* @f1 to void (i32, i32, i32)*)(i32 1, i32 2, i32 3)
Daniel Dunbard5d31802009-02-19 07:15:39 +000028 f1(1, 2, 3);
29}
John McCallb7d35892010-02-24 07:33:39 +000030// CHECK: define void @f1()
Daniel Dunbard5d31802009-02-19 07:15:39 +000031void f1() {}
Chris Lattnerff75e1d2009-03-22 19:35:37 +000032
John McCall1a4bb5c2010-02-24 08:14:27 +000033// CHECK: define {{.*}} @f3{{\(\)|\(.*sret.*\)}}
Chris Lattnerff75e1d2009-03-22 19:35:37 +000034struct foo { int X, Y, Z; } f3() {
Mike Stumpc36541e2009-07-21 20:52:43 +000035 while (1) {}
Chris Lattnerff75e1d2009-03-22 19:35:37 +000036}
Chris Lattnerd6bebbf2009-06-23 01:38:41 +000037
38// PR4423 - This shouldn't crash in codegen
39void f4() {}
John McCallb7d35892010-02-24 07:33:39 +000040void f5() { f4(42); } //expected-warning {{too many arguments}}
John McCall0b0ef0a2010-02-24 07:14:12 +000041
42// Qualifiers on parameter types shouldn't make a difference.
43static void f6(const float f, const float g) {
44}
45void f7(float f, float g) {
46 f6(f, g);
47// CHECK: define void @f7(float{{.*}}, float{{.*}})
48// CHECK: call void @f6(float{{.*}}, float{{.*}})
49}
John McCall784f2112010-04-28 00:00:30 +000050
51// PR6911 - incomplete function types
52struct Incomplete;
53void f8_callback(struct Incomplete);
54void f8_user(void (*callback)(struct Incomplete));
55void f8_test() {
56 f8_user(&f8_callback);
57// CHECK: define void @f8_test()
58// CHECK: call void @f8_user({{.*}}* bitcast (void ()* @f8_callback to {{.*}}*))
59// CHECK: declare void @f8_user({{.*}}*)
60// CHECK: declare void @f8_callback()
61}
John McCalla0b7d2e2011-06-27 22:57:05 +000062
63// PR10204: don't crash
64static void test9_helper(void) {}
65void test9() {
66 (void) test9_helper;
67}