Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST1 |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST2 -emit-llvm -o - | FileCheck %s |
| 3 | // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST3 |
| 4 | // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST4 |
Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 5 | |
| 6 | #ifdef TEST1 |
Argyrios Kyrtzidis | 4f1bb9c | 2013-11-24 17:05:58 +0000 | [diff] [blame] | 7 | |
| 8 | // rdar://15522601 |
| 9 | class MyClass { |
| 10 | static void meth(); |
| 11 | }; |
Richard Smith | 6d0e97a | 2014-08-02 00:50:16 +0000 | [diff] [blame] | 12 | void MyClass::meth() { } // expected-note {{previous}} |
Argyrios Kyrtzidis | 4f1bb9c | 2013-11-24 17:05:58 +0000 | [diff] [blame] | 13 | extern "C" { |
| 14 | void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name as another definition}} |
| 15 | } |
Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 16 | |
| 17 | #elif TEST2 |
| 18 | |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 19 | // expected-no-diagnostics |
| 20 | |
| 21 | // We expect no warnings here, as there is only declaration of _ZN1TD1Ev |
| 22 | // function, no definitions. |
Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 23 | extern "C" void _ZN1TD1Ev(); |
| 24 | struct T { |
| 25 | ~T() {} |
| 26 | }; |
| 27 | |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 28 | // We expect no warnings here, as there is only declaration of _ZN2nm3abcE |
| 29 | // global, no definitions. |
| 30 | extern "C" { |
| 31 | int _ZN2nm3abcE; |
Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 34 | namespace nm { |
| 35 | float abc = 2; |
| 36 | } |
| 37 | // CHECK: @_ZN2nm3abcE = global float |
| 38 | |
| 39 | float foo() { |
| 40 | _ZN1TD1Ev(); |
Andrey Bokhanko | 834ea68 | 2016-01-14 11:53:50 +0000 | [diff] [blame] | 41 | // CHECK: call void bitcast ({{.*}} (%struct.T*)* @_ZN1TD1Ev to void ()*)() |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 42 | T t; |
Andrey Bokhanko | 834ea68 | 2016-01-14 11:53:50 +0000 | [diff] [blame] | 43 | // CHECK: call {{.*}} @_ZN1TD1Ev(%struct.T* %t) |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 44 | return _ZN2nm3abcE + nm::abc; |
| 45 | } |
| 46 | |
| 47 | #elif TEST3 |
| 48 | |
Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 49 | extern "C" void _ZN2T2D2Ev() {}; // expected-note {{previous definition is here}} |
| 50 | |
| 51 | struct T2 { |
| 52 | ~T2() {} // expected-error {{definition with same mangled name as another definition}} |
| 53 | }; |
| 54 | |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 55 | void foo() { |
Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 56 | _ZN2T2D2Ev(); |
| 57 | T2 t; |
| 58 | } |
| 59 | |
Andrey Bokhanko | 7aa88ce | 2016-01-14 10:41:16 +0000 | [diff] [blame] | 60 | #elif TEST4 |
| 61 | |
| 62 | extern "C" { |
| 63 | int _ZN2nm3abcE = 1; // expected-note {{previous definition is here}} |
| 64 | } |
| 65 | |
| 66 | namespace nm { |
| 67 | float abc = 2; // expected-error {{definition with same mangled name as another definition}} |
| 68 | } |
| 69 | |
| 70 | float foo() { |
| 71 | return _ZN2nm3abcE + nm::abc; |
| 72 | } |
| 73 | |
Andrey Bokhanko | cab5858 | 2015-08-31 13:20:44 +0000 | [diff] [blame] | 74 | #else |
| 75 | |
| 76 | #error Unknwon test |
| 77 | |
| 78 | #endif |
| 79 | |