1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14 2 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 3 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -Wc++17-compat 4 5 namespace inline foo1::foo2::foo3 { // expected-error {{expected identifier or '{'}} expected-error {{use of undeclared identifier 'foo1'}} 6 } 7 8 inline namespace foo4::foo5::foo6 { // expected-error {{nested namespace definition cannot be 'inline'}}} 9 } 10 11 #if __cplusplus <= 201402L 12 // expected-warning@+7 {{nested namespace definition is a C++17 extension; define each namespace separately}} 13 // expected-warning@+6 {{inline nested namespace definition is a C++20 extension}} 14 #elif __cplusplus <= 201703L 15 // expected-warning@+4 {{inline nested namespace definition is a C++20 extension}} 16 #else 17 // expected-warning@+2 {{inline nested namespace definition is incompatible with C++ standards before C++20}} 18 #endif 19 namespace valid1::valid2::inline valid3::inline valid4::valid5 {} 20 // expected-note@-1 2 {{previous definition is here}} 21 22 #if __cplusplus <= 201402L 23 // expected-warning@+3 {{nested namespace definition is a C++17 extension; define each namespace separately}} 24 #endif 25 //expected-warning@+1 2 {{inline namespace reopened as a non-inline namespace}} 26 namespace valid1::valid2::valid3::valid4::valid5 {} 27 28 #if __cplusplus <= 201402L 29 // expected-warning@+7 {{nested namespace definition is a C++17 extension; define each namespace separately}} 30 // expected-warning@+6 {{inline nested namespace definition is a C++20 extension}} 31 #elif __cplusplus <= 201703L 32 // expected-warning@+4 {{inline nested namespace definition is a C++20 extension}} 33 #else 34 // expected-warning@+2 {{inline nested namespace definition is incompatible with C++ standards before C++20}} 35 #endif 36 namespace valid1::valid2::inline valid3::inline valid4::valid5 {} 37 // expected-note@-1 2 {{previous definition is here}} 38 39 namespace valid1 { 40 namespace valid2 { 41 //expected-warning@+1 {{inline namespace reopened as a non-inline namespace}} 42 namespace valid3 { 43 //expected-warning@+1 {{inline namespace reopened as a non-inline namespace}} 44 namespace valid4 { 45 namespace valid5 { 46 } 47 } // namespace valid4 48 } // namespace valid3 49 } // namespace valid2 50 } // namespace valid1 51 52