| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s |
| 3 |
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s |
| 4 |
|
| 5 |
namespace A { // expected-note 2 {{previous definition is here}} |
| 6 |
int A; |
| 7 |
void f() { A = 0; } |
| 8 |
} |
| 9 |
|
| 10 |
void f() { A = 0; } // expected-error {{unexpected namespace name 'A': expected expression}} |
| 11 |
int A; // expected-error {{redefinition of 'A' as different kind of symbol}} |
| 12 |
class A; // expected-error {{redefinition of 'A' as different kind of symbol}} |
| 13 |
|
| 14 |
class B {}; // expected-note {{previous definition is here}} |
| 15 |
// expected-note@-1 {{candidate function (the implicit copy assignment operator) not viable}} |
| 16 |
#if __cplusplus >= 201103L // C++11 or later |
| 17 |
// expected-note@-3 {{candidate function (the implicit move assignment operator) not viable}} |
| 18 |
#endif |
| 19 |
|
| 20 |
void C(); // expected-note {{previous definition is here}} |
| 21 |
namespace C {} // expected-error {{redefinition of 'C' as different kind of symbol}} |
| 22 |
|
| 23 |
namespace D { |
| 24 |
class D {}; |
| 25 |
} |
| 26 |
|
| 27 |
namespace S1 { |
| 28 |
int x; |
| 29 |
|
| 30 |
namespace S2 { |
| 31 |
|
| 32 |
namespace S3 { |
| 33 |
B x; |
| 34 |
} |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
namespace S1 { |
| 39 |
void f() { |
| 40 |
x = 0; |
| 41 |
} |
| 42 |
|
| 43 |
namespace S2 { |
| 44 |
|
| 45 |
namespace S3 { |
| 46 |
void f() { |
| 47 |
x = 0; // expected-error {{no viable overloaded '='}} |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
int y; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
namespace S1 { |
| 56 |
namespace S2 { |
| 57 |
namespace S3 { |
| 58 |
void f3() { |
| 59 |
y = 0; |
| 60 |
} |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
namespace B {} // expected-error {{redefinition of 'B' as different kind of symbol}} |
| 66 |
|
| 67 |
|
| 68 |
namespace foo { |
| 69 |
enum x { |
| 70 |
Y |
| 71 |
}; |
| 72 |
} |
| 73 |
|
| 74 |
static foo::x test1; // ok |
| 75 |
|
| 76 |
static foo::X test2; // typo: expected-error {{no type named 'X' in}} |
| 77 |
|
| 78 |
namespace PR6620 { |
| 79 |
namespace numeric { |
| 80 |
namespace op { |
| 81 |
struct greater {}; |
| 82 |
} |
| 83 |
namespace { |
| 84 |
extern op::greater const greater; |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
namespace numeric { |
| 89 |
namespace { |
| 90 |
op::greater const greater = op::greater(); |
| 91 |
} |
| 92 |
|
| 93 |
template<typename T, typename U> |
| 94 |
int f(T& l, U& r) |
| 95 |
{ numeric::greater(l, r); } |
| 96 |
|
| 97 |
} |
| 98 |
} |