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