xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/cxx1z-nested-namespace-definition.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: cp %s %t
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
3*0a6a1f1dSLionel Sambuc // RUN: not %clang_cc1 -x c++ -fixit %t -Werror -DFIXIT
4*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -x c++ %t -DFIXIT
5*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++1z -Wc++14-compat
6*0a6a1f1dSLionel Sambuc 
7*0a6a1f1dSLionel Sambuc namespace foo1::foo2::foo3 {
8*0a6a1f1dSLionel Sambuc #if __cplusplus <= 201400L
9*0a6a1f1dSLionel Sambuc // expected-warning@-2 {{nested namespace definition is a C++1z extension; define each namespace separately}}
10*0a6a1f1dSLionel Sambuc #else
11*0a6a1f1dSLionel Sambuc // expected-warning@-4 {{nested namespace definition is incompatible with C++ standards before C++1z}}
12*0a6a1f1dSLionel Sambuc #endif
foo(int x)13*0a6a1f1dSLionel Sambuc   int foo(int x) { return x; }
14*0a6a1f1dSLionel Sambuc }
15*0a6a1f1dSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc #ifndef FIXIT
17*0a6a1f1dSLionel Sambuc inline namespace goo::bar { // expected-error {{nested namespace definition cannot be 'inline'}} expected-warning 0-1{{C++11 feature}}
18*0a6a1f1dSLionel Sambuc   int n;
19*0a6a1f1dSLionel Sambuc }
20*0a6a1f1dSLionel Sambuc 
21*0a6a1f1dSLionel Sambuc int m = goo::bar::n;
22*0a6a1f1dSLionel Sambuc #endif
23*0a6a1f1dSLionel Sambuc 
foo(int x)24*0a6a1f1dSLionel Sambuc int foo(int x) {
25*0a6a1f1dSLionel Sambuc   return foo1::foo2::foo3::foo(x);
26*0a6a1f1dSLionel Sambuc }
27*0a6a1f1dSLionel Sambuc 
28*0a6a1f1dSLionel Sambuc namespace bar1 {
29*0a6a1f1dSLionel Sambuc   namespace bar2 {
30*0a6a1f1dSLionel Sambuc     namespace bar3 {
bar(int x)31*0a6a1f1dSLionel Sambuc       int bar(int x) { return x; }
32*0a6a1f1dSLionel Sambuc     }
33*0a6a1f1dSLionel Sambuc   }
34*0a6a1f1dSLionel Sambuc }
35*0a6a1f1dSLionel Sambuc 
bar(int x)36*0a6a1f1dSLionel Sambuc int bar(int x) {
37*0a6a1f1dSLionel Sambuc   return bar1::bar2::bar3::bar(x);
38*0a6a1f1dSLionel Sambuc }
39