John McCall | b7d3589 | 2010-02-24 07:33:39 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o - -verify | FileCheck %s |
Daniel Dunbar | d5d3180 | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 2 | |
Chris Lattner | 58c3f9e | 2007-12-02 06:27:33 +0000 | [diff] [blame] | 3 | int g(); |
| 4 | |
| 5 | int foo(int i) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 6 | return g(i); |
Chris Lattner | 58c3f9e | 2007-12-02 06:27:33 +0000 | [diff] [blame] | 7 | } |
| 8 | |
| 9 | int g(int i) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 10 | return g(i); |
Chris Lattner | 58c3f9e | 2007-12-02 06:27:33 +0000 | [diff] [blame] | 11 | } |
| 12 | |
Chris Lattner | 05d2fb4 | 2008-07-31 04:58:58 +0000 | [diff] [blame] | 13 | // rdar://6110827 |
| 14 | typedef void T(void); |
| 15 | void test3(T f) { |
| 16 | f(); |
| 17 | } |
| 18 | |
Douglas Gregor | 450da98 | 2009-02-16 20:58:07 +0000 | [diff] [blame] | 19 | int a(int); |
| 20 | int a() {return 1;} |
Daniel Dunbar | d5d3180 | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 21 | |
Daniel Dunbar | d5d3180 | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 22 | void f0() {} |
John McCall | b7d3589 | 2010-02-24 07:33:39 +0000 | [diff] [blame] | 23 | // CHECK: define void @f0() |
Daniel Dunbar | d5d3180 | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 24 | |
| 25 | void f1(); |
Daniel Dunbar | d5d3180 | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 26 | void f2(void) { |
John McCall | b7d3589 | 2010-02-24 07:33:39 +0000 | [diff] [blame] | 27 | // CHECK: call void @f1() |
Daniel Dunbar | d5d3180 | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 28 | f1(1, 2, 3); |
| 29 | } |
John McCall | b7d3589 | 2010-02-24 07:33:39 +0000 | [diff] [blame] | 30 | // CHECK: define void @f1() |
Daniel Dunbar | d5d3180 | 2009-02-19 07:15:39 +0000 | [diff] [blame] | 31 | void f1() {} |
Chris Lattner | ff75e1d | 2009-03-22 19:35:37 +0000 | [diff] [blame] | 32 | |
John McCall | 1a4bb5c | 2010-02-24 08:14:27 +0000 | [diff] [blame] | 33 | // CHECK: define {{.*}} @f3{{\(\)|\(.*sret.*\)}} |
Chris Lattner | ff75e1d | 2009-03-22 19:35:37 +0000 | [diff] [blame] | 34 | struct foo { int X, Y, Z; } f3() { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 35 | while (1) {} |
Chris Lattner | ff75e1d | 2009-03-22 19:35:37 +0000 | [diff] [blame] | 36 | } |
Chris Lattner | d6bebbf | 2009-06-23 01:38:41 +0000 | [diff] [blame] | 37 | |
| 38 | // PR4423 - This shouldn't crash in codegen |
| 39 | void f4() {} |
John McCall | b7d3589 | 2010-02-24 07:33:39 +0000 | [diff] [blame] | 40 | void f5() { f4(42); } //expected-warning {{too many arguments}} |
John McCall | 0b0ef0a | 2010-02-24 07:14:12 +0000 | [diff] [blame] | 41 | |
| 42 | // Qualifiers on parameter types shouldn't make a difference. |
| 43 | static void f6(const float f, const float g) { |
| 44 | } |
| 45 | void 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 McCall | 784f211 | 2010-04-28 00:00:30 +0000 | [diff] [blame] | 50 | |
| 51 | // PR6911 - incomplete function types |
| 52 | struct Incomplete; |
| 53 | void f8_callback(struct Incomplete); |
| 54 | void f8_user(void (*callback)(struct Incomplete)); |
| 55 | void 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 | } |