1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm-only %s -verify -DTEST1
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
5 
6 #ifdef TEST1
7 
8 // rdar://15522601
9 class MyClass {
10  static void meth();
11 };
meth()12 void MyClass::meth() { } // expected-note {{previous}}
13 extern "C" {
_ZN7MyClass4methEv()14   void _ZN7MyClass4methEv() { } // expected-error {{definition with same mangled name as another definition}}
15 }
16 
17 #elif TEST2
18 
19 // expected-no-diagnostics
20 
21 // We expect no warnings here, as there is only declaration of _ZN1TD1Ev
22 // function, no definitions.
23 extern "C" void _ZN1TD1Ev();
24 struct T {
~TT25   ~T() {}
26 };
27 
28 // We expect no warnings here, as there is only declaration of _ZN2nm3abcE
29 // global, no definitions.
30 extern "C" {
31   int _ZN2nm3abcE;
32 }
33 
34 namespace nm {
35   float abc = 2;
36 }
37 // CHECK: @_ZN2nm3abcE = global float
38 
foo()39 float foo() {
40   _ZN1TD1Ev();
41 // CHECK: call void bitcast ({{.*}} (%struct.T*)* @_ZN1TD1Ev to void ()*)()
42   T t;
43 // CHECK: call {{.*}} @_ZN1TD1Ev(%struct.T* %t)
44   return _ZN2nm3abcE + nm::abc;
45 }
46 
47 #elif TEST3
48 
_ZN2T2D2Ev()49 extern "C" void _ZN2T2D2Ev() {}; // expected-note {{previous definition is here}}
50 
51 struct T2 {
~T2T252   ~T2() {} // expected-error {{definition with same mangled name as another definition}}
53 };
54 
foo()55 void foo() {
56   _ZN2T2D2Ev();
57   T2 t;
58 }
59 
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 
foo()70 float foo() {
71   return _ZN2nm3abcE + nm::abc;
72 }
73 
74 #else
75 
76 #error Unknwon test
77 
78 #endif
79 
80