diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 |
commit | 9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (patch) | |
tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /test/CXX/dcl.dcl/basic.namespace | |
parent | f73d5f23a889b93d89ddef61ac0995df40286bb8 (diff) |
Notes
Diffstat (limited to 'test/CXX/dcl.dcl/basic.namespace')
4 files changed, 127 insertions, 15 deletions
diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp index c7966ce643f1b..4ffb93a1ef74d 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp @@ -1,14 +1,16 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// C++03 [namespace.udecl]p11: +// C++03 [namespace.udecl]p11: (per DR101) // If a function declaration in namespace scope or block scope has // the same name and the same parameter types as a function -// introduced by a using-declaration, the program is -// ill-formed. [Note: two using-declarations may introduce functions -// with the same name and the same parameter types. If, for a call -// to an unqualified function name, function overload resolution -// selects the functions introduced by such using-declarations, the -// function call is ill-formed. +// introduced by a using-declaration, and the declarations do not declare the +// same function, the program is ill-formed. [Note: two using-declarations may +// introduce functions with the same name and the same parameter types. If, +// for a call to an unqualified function name, function overload resolution +// selects the functions introduced by such using-declarations, the function +// call is ill-formed.] +// +// FIXME: DR565 introduces parallel wording here for function templates. namespace test0 { namespace ns { void foo(); } // expected-note {{target of using declaration}} @@ -89,3 +91,19 @@ namespace test5 { template class Test0<int>; template class Test1<int>; } + +namespace test6 { + namespace ns { void foo(); } // expected-note {{target of using declaration}} + using ns::foo; // expected-note {{using declaration}} + namespace ns { + using test6::foo; + void foo() {} + } + void foo(); // expected-error {{declaration conflicts with target of using declaration already in scope}} +} + +namespace test7 { + void foo(); + using test7::foo; + void foo() {} +} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp index edaa975a58905..35ef3b57b0cc2 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p5-cxx0x.cpp @@ -7,6 +7,6 @@ struct A { }; struct B : A { - using A::f<double>; // expected-error{{using declaration can not refer to a template specialization}} - using A::X<int>; // expected-error{{using declaration can not refer to a template specialization}} + using A::f<double>; // expected-error{{using declaration cannot refer to a template specialization}} + using A::X<int>; // expected-error{{using declaration cannot refer to a template specialization}} }; diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp index c4b8849e58cfc..c2fb95902454d 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p6-cxx0x.cpp @@ -5,4 +5,4 @@ namespace A { namespace B { } } -using A::B; // expected-error{{using declaration can not refer to namespace}} +using A::B; // expected-error{{using declaration cannot refer to namespace}} diff --git a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp index 78b5a41648a76..4f89dcfb3f522 100644 --- a/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp +++ b/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p8-cxx0x.cpp @@ -1,4 +1,7 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s +// RUN: not %clang_cc1 -fsyntax-only -std=c++98 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefix=CXX98 %s +// RUN: not %clang_cc1 -fsyntax-only -std=c++11 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefix=CXX11 %s // C++0x N2914. struct X { @@ -6,10 +9,101 @@ struct X { static int a; }; -using X::i; // expected-error{{using declaration can not refer to class member}} -using X::s; // expected-error{{using declaration can not refer to class member}} +using X::i; // expected-error{{using declaration cannot refer to class member}} +using X::s; // expected-error{{using declaration cannot refer to class member}} void f() { - using X::i; // expected-error{{using declaration can not refer to class member}} - using X::s; // expected-error{{using declaration can not refer to class member}} + using X::i; // expected-error{{using declaration cannot refer to class member}} + using X::s; // expected-error{{using declaration cannot refer to class member}} +} + +struct S { + static int n; + struct Q {}; + enum E {}; + typedef Q T; + void f(); + static void g(); +}; + +using S::n; // expected-error{{class member}} expected-note {{use a reference instead}} +#if __cplusplus < 201103L +// CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-2]] +#else +// CXX11: fix-it:"{{.*}}":{[[@LINE-4]]:1-[[@LINE-4]]:6}:"auto &n = " +#endif + +using S::Q; // expected-error{{class member}} +#if __cplusplus < 201103L +// expected-note@-2 {{use a typedef declaration instead}} +// CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef" +// CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" Q" +#else +// expected-note@-6 {{use an alias declaration instead}} +// CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"Q = " +#endif + +using S::E; // expected-error{{class member}} +#if __cplusplus < 201103L +// expected-note@-2 {{use a typedef declaration instead}} +// CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef" +// CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" E" +#else +// expected-note@-6 {{use an alias declaration instead}} +// CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"E = " +#endif + +using S::T; // expected-error{{class member}} +#if __cplusplus < 201103L +// expected-note@-2 {{use a typedef declaration instead}} +// CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:1-[[@LINE-3]]:6}:"typedef" +// CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:11-[[@LINE-4]]:11}:" T" +#else +// expected-note@-6 {{use an alias declaration instead}} +// CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:7-[[@LINE-7]]:7}:"T = " +#endif + +using S::f; // expected-error{{class member}} +using S::g; // expected-error{{class member}} + +void h() { + using S::n; // expected-error{{class member}} expected-note {{use a reference instead}} +#if __cplusplus < 201103L + // CXX98-NOT: fix-it:"{{.*}}":{[[@LINE-2]] +#else + // CXX11: fix-it:"{{.*}}":{[[@LINE-4]]:3-[[@LINE-4]]:8}:"auto &n = " +#endif + + using S::Q; // expected-error{{class member}} +#if __cplusplus < 201103L + // expected-note@-2 {{use a typedef declaration instead}} + // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef" + // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" Q" +#else + // expected-note@-6 {{use an alias declaration instead}} + // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"Q = " +#endif + + using S::E; // expected-error{{class member}} +#if __cplusplus < 201103L + // expected-note@-2 {{use a typedef declaration instead}} + // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef" + // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" E" +#else + // expected-note@-6 {{use an alias declaration instead}} + // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"E = " +#endif + + using S::T; // expected-error{{class member}} +#if __cplusplus < 201103L + // expected-note@-2 {{use a typedef declaration instead}} + // CXX98: fix-it:"{{.*}}":{[[@LINE-3]]:3-[[@LINE-3]]:8}:"typedef" + // CXX98: fix-it:"{{.*}}":{[[@LINE-4]]:13-[[@LINE-4]]:13}:" T" +#else + // expected-note@-6 {{use an alias declaration instead}} + // CXX11: fix-it:"{{.*}}":{[[@LINE-7]]:9-[[@LINE-7]]:9}:"T = " +#endif + + using S::f; // expected-error{{class member}} + using S::g; // expected-error{{class member}} } |