summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/using-decl-1.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerdim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit173a4f43a911175643bda81ee675e8d9269056ea (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /test/SemaCXX/using-decl-1.cpp
parent88f7a7d5251a2d813460274c92decc143a11569b (diff)
downloadFreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip
FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'test/SemaCXX/using-decl-1.cpp')
-rw-r--r--test/SemaCXX/using-decl-1.cpp97
1 files changed, 96 insertions, 1 deletions
diff --git a/test/SemaCXX/using-decl-1.cpp b/test/SemaCXX/using-decl-1.cpp
index 24d92f1..40f80a7 100644
--- a/test/SemaCXX/using-decl-1.cpp
+++ b/test/SemaCXX/using-decl-1.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
extern "C" { void f(bool); }
@@ -160,3 +161,97 @@ namespace M { }
}
using N::M::FFF; // expected-error {{no member named 'FFF' in namespace 'using_suggestion_val_dropped_nested_specifier::N::M'; did you mean 'N::FFF'?}}
}
+
+namespace UsingDeclVsHiddenName {
+ namespace A {
+ enum HiddenTag1 {}; // expected-note {{previous use is here}}
+ enum HiddenTag2 {}; // expected-note {{target}}
+ int HiddenFn1; // expected-note {{target}}
+ int HiddenFn2; // expected-note {{target}}
+ int HiddenLocalExtern1;
+ int HiddenLocalExtern2;
+ }
+
+ namespace B {
+ using A::HiddenTag1;
+ using A::HiddenFn1; // expected-note {{using declaration}}
+ using A::HiddenLocalExtern1;
+
+ struct S {
+ friend struct HiddenTag1; // expected-error {{tag type that does not match previous}}
+ friend struct HiddenTag2; // expected-note {{conflicting declaration}}
+ friend void HiddenFn1(); // expected-error {{cannot befriend target of using declaration}}
+ friend void HiddenFn2(); // expected-note {{conflicting declaration}}
+ void f() {
+ // OK, these are not in the scope of namespace B, even though they're
+ // members of the namespace.
+ void HiddenLocalExtern1();
+ void HiddenLocalExtern2();
+ }
+ };
+
+ using A::HiddenTag2; // expected-error {{conflicts with declaration already in scope}}
+ using A::HiddenFn2; // expected-error {{conflicts with declaration already in scope}}
+ using A::HiddenLocalExtern2;
+ }
+}
+
+namespace PR19171 {
+ struct Z {
+ Z();
+ };
+
+ typedef struct {
+ Z i;
+ } S;
+
+ struct Y : S {
+ using S::S;
+#if __cplusplus < 201103L
+ // expected-error@-2 {{no member named 'S' in 'PR19171::S'}}
+#endif
+ };
+
+ // [namespace.udecl]p3: In a using-declaration used as a member-declaration,
+ // the nested-name-specifier shall name a base class of the class being defined.
+ // If such a using-declaration names a constructor, the nested-name-specifier
+ // shall name a direct base class of the class being defined;
+
+ struct B_blah { };
+ struct C_blah : B_blah { C_blah(int); }; // expected-note 0-1{{declared here}}
+ struct D1 : C_blah {
+ // FIXME: We should be able to correct this in C++11 mode.
+ using B_blah::C_blah; // expected-error-re {{no member named 'C_blah' in 'PR19171::B_blah'{{$}}}}
+ };
+ struct D2 : C_blah {
+ // Somewhat bizarrely, this names the injected-class-name of B_blah within
+ // C_blah, and is valid.
+ using C_blah::B_blah;
+ };
+ struct D3 : C_blah {
+ using C_blah::D_blah;
+#if __cplusplus < 201103L
+ // expected-error-re@-2 {{no member named 'D_blah' in 'PR19171::C_blah'{{$}}}}
+#else
+ // expected-error@-4 {{no member named 'D_blah' in 'PR19171::C_blah'; did you mean 'C_blah'?}}
+#endif
+ };
+#if __cplusplus >= 201103L
+ D3 d3(0); // ok
+#endif
+
+ struct E { };
+ struct EE { int EE; };
+ struct F : E {
+ using E::EE; // expected-error-re {{no member named 'EE' in 'PR19171::E'{{$}}}}
+ };
+}
+
+namespace TypoCorrectTemplateMember {
+ struct A {
+ template<typename T> void foobar(T); // expected-note {{'foobar' declared here}}
+ };
+ struct B : A {
+ using A::goobar; // expected-error {{no member named 'goobar' in 'TypoCorrectTemplateMember::A'; did you mean 'foobar'?}}
+ };
+}
OpenPOWER on IntegriCloud