blob: d47b7076cec2ea8919b4d66dd34617d76ba11b43 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Sebastian Redl3cb06922009-02-07 19:52:04 +00002namespace A { // expected-note 2 {{previous definition is here}}
Ted Kremenekdd6cec12008-04-29 04:43:50 +00003 int A;
4 void f() { A = 0; }
5}
6
Chris Lattner5f4a6822008-11-23 23:12:31 +00007void f() { A = 0; } // expected-error {{unexpected namespace name 'A': expected expression}}
8int A; // expected-error {{redefinition of 'A' as different kind of symbol}}
9class A; // expected-error {{redefinition of 'A' as different kind of symbol}}
Ted Kremenekdd6cec12008-04-29 04:43:50 +000010
Douglas Gregor33074752009-09-30 21:46:01 +000011class B {}; // expected-note {{previous definition is here}} \
John McCall220ccbf2010-01-13 00:25:19 +000012 // expected-note{{candidate function (the implicit copy assignment operator)}}
Ted Kremenekdd6cec12008-04-29 04:43:50 +000013
Chris Lattner5f4a6822008-11-23 23:12:31 +000014void C(); // expected-note {{previous definition is here}}
15namespace C {} // expected-error {{redefinition of 'C' as different kind of symbol}}
Argyrios Kyrtzidis00bc6452008-05-09 23:39:43 +000016
Argyrios Kyrtzidisb02ef242008-07-16 07:45:46 +000017namespace D {
18 class D {};
19}
20
Argyrios Kyrtzidis00bc6452008-05-09 23:39:43 +000021namespace S1 {
22 int x;
23
24 namespace S2 {
25
26 namespace S3 {
27 B x;
28 }
29 }
30}
31
32namespace S1 {
33 void f() {
34 x = 0;
35 }
36
37 namespace S2 {
38
39 namespace S3 {
40 void f() {
Sebastian Redl8593c782009-05-21 11:50:50 +000041 x = 0; // expected-error {{no viable overloaded '='}}
Argyrios Kyrtzidis00bc6452008-05-09 23:39:43 +000042 }
43 }
44
45 int y;
46 }
47}
48
49namespace S1 {
50 namespace S2 {
51 namespace S3 {
52 void f3() {
53 y = 0;
54 }
55 }
56 }
57}
Douglas Gregor44b43212008-12-11 16:49:14 +000058
59namespace B {} // expected-error {{redefinition of 'B' as different kind of symbol}}
Chris Lattnerf4382f52009-04-14 22:17:06 +000060
61
62namespace foo {
63 enum x {
64 Y
65 };
66}
67
68static foo::x test1; // ok
69
Douglas Gregora786fdb2009-10-13 23:27:22 +000070static foo::X test2; // typo: expected-error {{no type named 'X' in}}
Douglas Gregora4181472010-03-24 00:46:35 +000071
72namespace PR6620 {
73 namespace numeric {
74 namespace op {
75 struct greater {};
76 }
77 namespace {
78 extern op::greater const greater;
79 }
80 }
81
82 namespace numeric {
83 namespace {
84 op::greater const greater = op::greater();
85 }
86
87 template<typename T, typename U>
88 int f(T& l, U& r)
89 { numeric::greater(l, r); }
90
91 }
92}