Richard Smith | 13307f5 | 2014-11-08 05:37:34 +0000 | [diff] [blame] | 1 | // RUN: cp %s %t |
Tim Northover | 36bb6d5 | 2017-12-09 12:09:54 +0000 | [diff] [blame^] | 2 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 |
Richard Smith | 13307f5 | 2014-11-08 05:37:34 +0000 | [diff] [blame] | 3 | // RUN: not %clang_cc1 -x c++ -fixit %t -Werror -DFIXIT |
| 4 | // RUN: %clang_cc1 -x c++ %t -DFIXIT |
Richard Smith | cbaaa29 | 2017-08-13 22:26:53 +0000 | [diff] [blame] | 5 | // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -Wc++14-compat |
Richard Smith | 13307f5 | 2014-11-08 05:37:34 +0000 | [diff] [blame] | 6 | |
| 7 | namespace foo1::foo2::foo3 { |
| 8 | #if __cplusplus <= 201400L |
Richard Smith | cbaaa29 | 2017-08-13 22:26:53 +0000 | [diff] [blame] | 9 | // expected-warning@-2 {{nested namespace definition is a C++17 extension; define each namespace separately}} |
Richard Smith | 13307f5 | 2014-11-08 05:37:34 +0000 | [diff] [blame] | 10 | #else |
Richard Smith | cbaaa29 | 2017-08-13 22:26:53 +0000 | [diff] [blame] | 11 | // expected-warning@-4 {{nested namespace definition is incompatible with C++ standards before C++17}} |
Richard Smith | 13307f5 | 2014-11-08 05:37:34 +0000 | [diff] [blame] | 12 | #endif |
| 13 | int foo(int x) { return x; } |
| 14 | } |
| 15 | |
| 16 | #ifndef FIXIT |
| 17 | inline namespace goo::bar { // expected-error {{nested namespace definition cannot be 'inline'}} expected-warning 0-1{{C++11 feature}} |
| 18 | int n; |
| 19 | } |
| 20 | |
| 21 | int m = goo::bar::n; |
| 22 | #endif |
| 23 | |
| 24 | int foo(int x) { |
| 25 | return foo1::foo2::foo3::foo(x); |
| 26 | } |
| 27 | |
| 28 | namespace bar1 { |
| 29 | namespace bar2 { |
| 30 | namespace bar3 { |
| 31 | int bar(int x) { return x; } |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | int bar(int x) { |
| 37 | return bar1::bar2::bar3::bar(x); |
| 38 | } |