Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - %s | FileCheck %s |
Douglas Gregor | 457e281 | 2009-10-28 16:31:34 +0000 | [diff] [blame] | 2 | |
| 3 | // CHECK: @"\01foo" |
Daniel Dunbar | 524ed95 | 2009-02-20 23:09:27 +0000 | [diff] [blame] | 4 | |
| 5 | // Make sure we mangle overloadable, even in C system headers. |
Daniel Dunbar | 524ed95 | 2009-02-20 23:09:27 +0000 | [diff] [blame] | 6 | # 1 "somesystemheader.h" 1 3 4 |
Douglas Gregor | 457e281 | 2009-10-28 16:31:34 +0000 | [diff] [blame] | 7 | // CHECK: @_Z2f0i |
Daniel Dunbar | 524ed95 | 2009-02-20 23:09:27 +0000 | [diff] [blame] | 8 | void __attribute__((__overloadable__)) f0(int a) {} |
Douglas Gregor | 457e281 | 2009-10-28 16:31:34 +0000 | [diff] [blame] | 9 | // CHECK: @_Z2f0l |
Daniel Dunbar | 524ed95 | 2009-02-20 23:09:27 +0000 | [diff] [blame] | 10 | void __attribute__((__overloadable__)) f0(long b) {} |
Chris Lattner | ca3f25c | 2009-03-21 08:24:40 +0000 | [diff] [blame] | 11 | |
Douglas Gregor | 457e281 | 2009-10-28 16:31:34 +0000 | [diff] [blame] | 12 | // CHECK: @"\01bar" |
Chris Lattner | ca3f25c | 2009-03-21 08:24:40 +0000 | [diff] [blame] | 13 | |
| 14 | // These should get merged. |
| 15 | void foo() __asm__("bar"); |
| 16 | void foo2() __asm__("bar"); |
| 17 | |
Chris Lattner | ca3f25c | 2009-03-21 08:24:40 +0000 | [diff] [blame] | 18 | int nux __asm__("foo"); |
| 19 | extern float nux2 __asm__("foo"); |
| 20 | |
| 21 | int test() { |
| 22 | foo(); |
| 23 | foo2(); |
| 24 | |
| 25 | return nux + nux2; |
| 26 | } |
Chris Lattner | 570585c | 2009-03-21 09:16:30 +0000 | [diff] [blame] | 27 | |
| 28 | |
| 29 | // Function becomes a variable. |
| 30 | void foo3() __asm__("var"); |
| 31 | |
| 32 | void test2() { |
| 33 | foo3(); |
| 34 | } |
| 35 | int foo4 __asm__("var") = 4; |
| 36 | |
Chris Lattner | 0558e79 | 2009-03-21 09:25:43 +0000 | [diff] [blame] | 37 | |
| 38 | // Variable becomes a function |
| 39 | extern int foo5 __asm__("var2"); |
| 40 | |
| 41 | void test3() { |
| 42 | foo5 = 1; |
| 43 | } |
| 44 | |
| 45 | void foo6() __asm__("var2"); |
| 46 | void foo6() { |
| 47 | } |
Chris Lattner | 35f38a2 | 2009-03-31 22:37:52 +0000 | [diff] [blame] | 48 | |
| 49 | |
| 50 | |
| 51 | int foo7 __asm__("foo7") __attribute__((used)); |
| 52 | float foo8 __asm__("foo7") = 42; |
Douglas Gregor | 457e281 | 2009-10-28 16:31:34 +0000 | [diff] [blame] | 53 | |
| 54 | // PR4412 |
| 55 | int func(void); |
| 56 | extern int func (void) __asm__ ("FUNC"); |
| 57 | |
| 58 | // CHECK: @"\01FUNC" |
| 59 | int func(void) { |
| 60 | return 42; |
| 61 | } |