Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame^] | 1 | // RUN: echo "GNU89 tests:" |
| 2 | // RUN: clang %s -emit-llvm -S -o %t -std=gnu89 |
| 3 | // RUN: grep "define available_externally i32 @ei()" %t |
| 4 | // RUN: grep "define i32 @foo()" %t |
| 5 | // RUN: grep "define i32 @bar()" %t |
| 6 | // RUN: grep "define void @unreferenced1()" %t |
| 7 | // RUN: not grep unreferenced2 %t |
| 8 | // RUN: grep "define void @gnu_inline()" %t |
| 9 | // RUN: grep "define available_externally void @gnu_ei_inline()" %t |
| 10 | // RUN: grep "define i32 @test1" %t |
| 11 | // RUN: grep "define i32 @test2" %t |
| 12 | // RUN: grep "define void @test3()" %t |
| 13 | // RUN: grep "define available_externally i32 @test4" %t |
| 14 | // RUN: grep "define available_externally i32 @test5" %t |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 15 | |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame^] | 16 | // RUN: echo "\nC99 tests:" |
| 17 | // RUN: clang %s -emit-llvm -S -o %t -std=c99 |
| 18 | // RUN: grep "define i32 @ei()" %t |
| 19 | // RUN: grep "define available_externally i32 @foo()" %t |
| 20 | // RUN: grep "define i32 @bar()" %t |
| 21 | // RUN: not grep unreferenced1 %t |
| 22 | // RUN: grep "define void @unreferenced2()" %t |
| 23 | // RUN: grep "define void @gnu_inline()" %t |
| 24 | // RUN: grep "define available_externally void @gnu_ei_inline()" %t |
| 25 | // RUN: grep "define i32 @test1" %t |
| 26 | // RUN: grep "define i32 @test2" %t |
| 27 | // RUN: grep "define void @test3" %t |
| 28 | // RUN: grep "define available_externally i32 @test4" %t |
| 29 | // RUN: grep "define available_externally i32 @test5" %t |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 30 | |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame^] | 31 | // RUN: echo "\nC++ tests:" |
| 32 | // RUN: clang %s -emit-llvm -S -o %t -std=c++98 |
| 33 | // RUN: grep "define linkonce_odr i32 @_Z2eiv()" %t |
| 34 | // RUN: grep "define linkonce_odr i32 @_Z3foov()" %t |
| 35 | // RUN: grep "define i32 @_Z3barv()" %t |
| 36 | // RUN: not grep unreferenced %t |
| 37 | // RUN: grep "define void @_Z10gnu_inlinev()" %t |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 38 | // RUN: grep "define available_externally void @_Z13gnu_ei_inlinev()" %t |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 39 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 40 | extern __inline int ei() { return 123; } |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 41 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 42 | __inline int foo() { |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 43 | return ei(); |
| 44 | } |
| 45 | |
| 46 | int bar() { return foo(); } |
| 47 | |
| 48 | |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 49 | __inline void unreferenced1() {} |
| 50 | extern __inline void unreferenced2() {} |
Chris Lattner | d9d049a | 2009-04-14 06:27:57 +0000 | [diff] [blame] | 51 | |
Chris Lattner | cf2a721 | 2009-04-20 19:12:28 +0000 | [diff] [blame] | 52 | __inline __attribute((__gnu_inline__)) void gnu_inline() {} |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 53 | |
| 54 | // PR3988 |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 55 | extern __inline __attribute__((gnu_inline)) void gnu_ei_inline() {} |
Chris Lattner | d55a71d | 2009-04-22 00:03:30 +0000 | [diff] [blame] | 56 | void (*P)() = gnu_ei_inline; |
| 57 | |
Douglas Gregor | b3efa98 | 2009-04-23 18:22:55 +0000 | [diff] [blame] | 58 | // <rdar://problem/6818429> |
| 59 | int test1(); |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 60 | __inline int test1() { return 4; } |
| 61 | __inline int test2() { return 5; } |
| 62 | __inline int test2(); |
Douglas Gregor | b3efa98 | 2009-04-23 18:22:55 +0000 | [diff] [blame] | 63 | int test2(); |
| 64 | |
| 65 | void test_test1() { test1(); } |
| 66 | void test_test2() { test2(); } |
| 67 | |
| 68 | // PR3989 |
Eli Friedman | eb32fde | 2009-04-28 03:13:54 +0000 | [diff] [blame] | 69 | extern __inline void test3() __attribute__((gnu_inline)); |
Douglas Gregor | 1fc09a9 | 2009-09-13 07:46:26 +0000 | [diff] [blame] | 70 | __inline void __attribute__((gnu_inline)) test3() {} |
Douglas Gregor | 9f9bf25 | 2009-04-28 06:37:30 +0000 | [diff] [blame] | 71 | |
| 72 | extern int test4(void); |
| 73 | extern __inline __attribute__ ((__gnu_inline__)) int test4(void) |
| 74 | { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 75 | return 0; |
Douglas Gregor | 9f9bf25 | 2009-04-28 06:37:30 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | void test_test4() { test4(); } |
| 79 | |
Douglas Gregor | 1fc09a9 | 2009-09-13 07:46:26 +0000 | [diff] [blame] | 80 | extern __inline int test5(void) __attribute__ ((__gnu_inline__)); |
Douglas Gregor | 9f9bf25 | 2009-04-28 06:37:30 +0000 | [diff] [blame] | 81 | extern __inline int __attribute__ ((__gnu_inline__)) test5(void) |
| 82 | { |
Mike Stump | c36541e | 2009-07-21 20:52:43 +0000 | [diff] [blame] | 83 | return 0; |
Douglas Gregor | 9f9bf25 | 2009-04-28 06:37:30 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | void test_test5() { test5(); } |