blob: 8c8f6e0311c3b572c1fc7cc333408ddd476272e3 [file] [log] [blame]
Andrey Bokhankocab58582015-08-31 13:20:44 +00001// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST1
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +00002// 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 Bokhankocab58582015-08-31 13:20:44 +00005
6#ifdef TEST1
Argyrios Kyrtzidis4f1bb9c2013-11-24 17:05:58 +00007
8// rdar://15522601
9class MyClass {
10 static void meth();
11};
Richard Smith6d0e97a2014-08-02 00:50:16 +000012void MyClass::meth() { } // expected-note {{previous}}
Argyrios Kyrtzidis4f1bb9c2013-11-24 17:05:58 +000013extern "C" {
14 void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name as another definition}}
15}
Andrey Bokhankocab58582015-08-31 13:20:44 +000016
17#elif TEST2
18
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +000019// expected-no-diagnostics
20
21// We expect no warnings here, as there is only declaration of _ZN1TD1Ev
22// function, no definitions.
Andrey Bokhankocab58582015-08-31 13:20:44 +000023extern "C" void _ZN1TD1Ev();
24struct T {
25 ~T() {}
26};
27
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +000028// We expect no warnings here, as there is only declaration of _ZN2nm3abcE
29// global, no definitions.
30extern "C" {
31 int _ZN2nm3abcE;
Andrey Bokhankocab58582015-08-31 13:20:44 +000032}
33
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +000034namespace nm {
35 float abc = 2;
36}
37// CHECK: @_ZN2nm3abcE = global float
38
39float foo() {
40 _ZN1TD1Ev();
Andrey Bokhanko834ea682016-01-14 11:53:50 +000041// CHECK: call void bitcast ({{.*}} (%struct.T*)* @_ZN1TD1Ev to void ()*)()
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +000042 T t;
Andrey Bokhanko834ea682016-01-14 11:53:50 +000043// CHECK: call {{.*}} @_ZN1TD1Ev(%struct.T* %t)
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +000044 return _ZN2nm3abcE + nm::abc;
45}
46
47#elif TEST3
48
Andrey Bokhankocab58582015-08-31 13:20:44 +000049extern "C" void _ZN2T2D2Ev() {}; // expected-note {{previous definition is here}}
50
51struct T2 {
52 ~T2() {} // expected-error {{definition with same mangled name as another definition}}
53};
54
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +000055void foo() {
Andrey Bokhankocab58582015-08-31 13:20:44 +000056 _ZN2T2D2Ev();
57 T2 t;
58}
59
Andrey Bokhanko7aa88ce2016-01-14 10:41:16 +000060#elif TEST4
61
62extern "C" {
63 int _ZN2nm3abcE = 1; // expected-note {{previous definition is here}}
64}
65
66namespace nm {
67 float abc = 2; // expected-error {{definition with same mangled name as another definition}}
68}
69
70float foo() {
71 return _ZN2nm3abcE + nm::abc;
72}
73
Andrey Bokhankocab58582015-08-31 13:20:44 +000074#else
75
76#error Unknwon test
77
78#endif
79