99 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s4 5namespace A { // expected-note 2 {{previous definition is here}}6 int A;7 void f() { A = 0; }8}9 10void f() { A = 0; } // expected-error {{unexpected namespace name 'A': expected expression}}11int A; // expected-error {{redefinition of 'A' as different kind of symbol}}12class A; // expected-error {{redefinition of 'A' as different kind of symbol}}13 14class 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 later17// expected-note@-3 {{candidate function (the implicit move assignment operator) not viable}}18#endif19 20void C(); // expected-note {{previous definition is here}}21namespace C {} // expected-error {{redefinition of 'C' as different kind of symbol}}22 23namespace D {24 class D {};25}26 27namespace S1 {28 int x;29 30 namespace S2 {31 32 namespace S3 {33 B x;34 }35 }36}37 38namespace 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 55namespace S1 {56 namespace S2 {57 namespace S3 {58 void f3() {59 y = 0;60 }61 }62 }63}64 65namespace B {} // expected-error {{redefinition of 'B' as different kind of symbol}}66 67 68namespace foo {69 enum x {70 Y71 };72}73 74static foo::x test1; // ok75 76static foo::X test2; // typo: expected-error {{no type named 'X' in}}77 78namespace 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}99