Chris Lattner | 86daeee | 2009-04-14 16:44:36 +0000 | [diff] [blame] | 1 | // RUN: echo "C89 tests:" && |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 2 | // RUN: clang %s -emit-llvm -S -o %t -std=c89 && |
| 3 | // RUN: grep "define available_externally i32 @ei()" %t && |
| 4 | // RUN: grep "define i32 @foo()" %t && |
| 5 | // RUN: grep "define i32 @bar()" %t && |
Chris Lattner | dbb5a37 | 2009-04-14 06:44:48 +0000 | [diff] [blame] | 6 | // RUN: grep "define void @unreferenced1()" %t && |
| 7 | // RUN: not grep unreferenced2 %t && |
Chris Lattner | 86daeee | 2009-04-14 16:44:36 +0000 | [diff] [blame] | 8 | // RUN: grep "define void @gnu_inline()" %t && |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 9 | // RUN: grep "define available_externally void @gnu_ei_inline()" %t && |
Douglas Gregor | b3efa98 | 2009-04-23 18:22:55 +0000 | [diff] [blame] | 10 | // RUN: grep "define void @test3()" %t && |
| 11 | // RUN: grep "define i32 @test1" %t && |
| 12 | // RUN: grep "define i32 @test2" %t && |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 13 | |
Chris Lattner | 86daeee | 2009-04-14 16:44:36 +0000 | [diff] [blame] | 14 | // RUN: echo "\nC99 tests:" && |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 15 | // RUN: clang %s -emit-llvm -S -o %t -std=c99 && |
Chris Lattner | cbb8fc1 | 2009-04-14 20:25:53 +0000 | [diff] [blame] | 16 | // RUN: grep "define i32 @ei()" %t && |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 17 | // RUN: grep "define available_externally i32 @foo()" %t && |
| 18 | // RUN: grep "define i32 @bar()" %t && |
Chris Lattner | cbb8fc1 | 2009-04-14 20:25:53 +0000 | [diff] [blame] | 19 | // RUN: not grep unreferenced1 %t && |
| 20 | // RUN: grep "define void @unreferenced2()" %t && |
Chris Lattner | 86daeee | 2009-04-14 16:44:36 +0000 | [diff] [blame] | 21 | // RUN: grep "define void @gnu_inline()" %t && |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 22 | // RUN: grep "define available_externally void @gnu_ei_inline()" %t && |
Douglas Gregor | b3efa98 | 2009-04-23 18:22:55 +0000 | [diff] [blame] | 23 | // RUN: grep "define i32 @test1" %t && |
| 24 | // RUN: grep "define i32 @test2" %t && |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 25 | |
Chris Lattner | 86daeee | 2009-04-14 16:44:36 +0000 | [diff] [blame] | 26 | // RUN: echo "\nC++ tests:" && |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 27 | // RUN: clang %s -emit-llvm -S -o %t -std=c++98 && |
Chris Lattner | cbb8fc1 | 2009-04-14 20:25:53 +0000 | [diff] [blame] | 28 | // RUN: grep "define linkonce_odr i32 @_Z2eiv()" %t && |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 29 | // RUN: grep "define linkonce_odr i32 @_Z3foov()" %t && |
| 30 | // RUN: grep "define i32 @_Z3barv()" %t && |
Chris Lattner | 86daeee | 2009-04-14 16:44:36 +0000 | [diff] [blame] | 31 | // RUN: not grep unreferenced %t && |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 32 | // RUN: grep "define void @_Z10gnu_inlinev()" %t && |
| 33 | // RUN: grep "define available_externally void @_Z13gnu_ei_inlinev()" %t |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 34 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame^] | 35 | extern __inline int ei() { return 123; } |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 36 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame^] | 37 | __inline int foo() { |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 38 | return ei(); |
| 39 | } |
| 40 | |
| 41 | int bar() { return foo(); } |
| 42 | |
| 43 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame^] | 44 | __inline void unreferenced1() {} |
| 45 | extern __inline void unreferenced2() {} |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 46 | |
Chris Lattner | cf2a721 | 2009-04-20 19:12:28 +0000 | [diff] [blame] | 47 | __inline __attribute((__gnu_inline__)) void gnu_inline() {} |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 48 | |
| 49 | // PR3988 |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame^] | 50 | extern __inline __attribute__((gnu_inline)) void gnu_ei_inline() {} |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 51 | void (*P)() = gnu_ei_inline; |
| 52 | |
Douglas Gregor | b3efa98 | 2009-04-23 18:22:55 +0000 | [diff] [blame] | 53 | // <rdar://problem/6818429> |
| 54 | int test1(); |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame^] | 55 | __inline int test1() { return 4; } |
| 56 | __inline int test2() { return 5; } |
| 57 | __inline int test2(); |
Douglas Gregor | b3efa98 | 2009-04-23 18:22:55 +0000 | [diff] [blame] | 58 | int test2(); |
| 59 | |
| 60 | void test_test1() { test1(); } |
| 61 | void test_test2() { test2(); } |
| 62 | |
| 63 | // PR3989 |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame^] | 64 | extern __inline void test3() __attribute__((gnu_inline)); |
| 65 | __inline void test3() {} |