Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Sebastian Redl | 3cb0692 | 2009-02-07 19:52:04 +0000 | [diff] [blame] | 2 | namespace A { // expected-note 2 {{previous definition is here}} |
Ted Kremenek | dd6cec1 | 2008-04-29 04:43:50 +0000 | [diff] [blame] | 3 | int A; |
| 4 | void f() { A = 0; } |
| 5 | } |
| 6 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 7 | void f() { A = 0; } // expected-error {{unexpected namespace name 'A': expected expression}} |
| 8 | int A; // expected-error {{redefinition of 'A' as different kind of symbol}} |
| 9 | class A; // expected-error {{redefinition of 'A' as different kind of symbol}} |
Ted Kremenek | dd6cec1 | 2008-04-29 04:43:50 +0000 | [diff] [blame] | 10 | |
Douglas Gregor | 3307475 | 2009-09-30 21:46:01 +0000 | [diff] [blame] | 11 | class B {}; // expected-note {{previous definition is here}} \ |
John McCall | 220ccbf | 2010-01-13 00:25:19 +0000 | [diff] [blame] | 12 | // expected-note{{candidate function (the implicit copy assignment operator)}} |
Ted Kremenek | dd6cec1 | 2008-04-29 04:43:50 +0000 | [diff] [blame] | 13 | |
Chris Lattner | 5f4a682 | 2008-11-23 23:12:31 +0000 | [diff] [blame] | 14 | void C(); // expected-note {{previous definition is here}} |
| 15 | namespace C {} // expected-error {{redefinition of 'C' as different kind of symbol}} |
Argyrios Kyrtzidis | 00bc645 | 2008-05-09 23:39:43 +0000 | [diff] [blame] | 16 | |
Argyrios Kyrtzidis | b02ef24 | 2008-07-16 07:45:46 +0000 | [diff] [blame] | 17 | namespace D { |
| 18 | class D {}; |
| 19 | } |
| 20 | |
Argyrios Kyrtzidis | 00bc645 | 2008-05-09 23:39:43 +0000 | [diff] [blame] | 21 | namespace S1 { |
| 22 | int x; |
| 23 | |
| 24 | namespace S2 { |
| 25 | |
| 26 | namespace S3 { |
| 27 | B x; |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | namespace S1 { |
| 33 | void f() { |
| 34 | x = 0; |
| 35 | } |
| 36 | |
| 37 | namespace S2 { |
| 38 | |
| 39 | namespace S3 { |
| 40 | void f() { |
Sebastian Redl | 8593c78 | 2009-05-21 11:50:50 +0000 | [diff] [blame] | 41 | x = 0; // expected-error {{no viable overloaded '='}} |
Argyrios Kyrtzidis | 00bc645 | 2008-05-09 23:39:43 +0000 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | |
| 45 | int y; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | namespace S1 { |
| 50 | namespace S2 { |
| 51 | namespace S3 { |
| 52 | void f3() { |
| 53 | y = 0; |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 58 | |
| 59 | namespace B {} // expected-error {{redefinition of 'B' as different kind of symbol}} |
Chris Lattner | f4382f5 | 2009-04-14 22:17:06 +0000 | [diff] [blame] | 60 | |
| 61 | |
| 62 | namespace foo { |
| 63 | enum x { |
| 64 | Y |
| 65 | }; |
| 66 | } |
| 67 | |
| 68 | static foo::x test1; // ok |
| 69 | |
Douglas Gregor | a786fdb | 2009-10-13 23:27:22 +0000 | [diff] [blame] | 70 | static foo::X test2; // typo: expected-error {{no type named 'X' in}} |
Douglas Gregor | a418147 | 2010-03-24 00:46:35 +0000 | [diff] [blame] | 71 | |
| 72 | namespace 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 | } |