"use of tagged type %0 without '%1' tag">;
def err_expected_ident_in_using : Error<
"expected an identifier in using directive">;
-def err_unexpected_template_spec_in_using : Error<
- "use of template specialization in using directive not allowed">;
+def err_using_decl_can_not_refer_to_template_spec : Error<
+ "using declaration can not refer to template specialization">;
/// Objective-C parser diagnostics
"dependent using declaration not supported yet">;
def err_using_decl_nested_name_specifier_is_not_a_base_class : Error<
"using declaration refers into %0, which is not a base class of %1">;
-def err_using_decl_refers_to_class_member : Error<
- "using declaration refers to class member">;
-
+def err_using_decl_can_not_refer_to_class_member : Error<
+ "using declaration can not refer to class member">;
+ def err_using_decl_can_not_refer_to_namespace : Error<
+ "using declaration can not refer to namespace">;
+
def err_invalid_thread : Error<
"'__thread' is only allowed on variable declarations">;
def err_thread_non_global : Error<
return DeclPtrTy();
}
if (Tok.is(tok::annot_template_id)) {
- Diag(Tok, diag::err_unexpected_template_spec_in_using);
+ // C++0x N2914 [namespace.udecl]p5:
+ // A using-declaration shall not name a template-id.
+ Diag(Tok, diag::err_using_decl_can_not_refer_to_template_spec);
SkipUntil(tok::semi);
return DeclPtrTy();
}
// C++0x N2914 [namespace.udecl]p8:
// A using-declaration for a class member shall be a member-declaration.
if (NNS->getKind() == NestedNameSpecifier::TypeSpec) {
- Diag(IdentLoc, diag::err_using_decl_refers_to_class_member)
+ Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_class_member)
<< SS.getRange();
return DeclPtrTy();
}
return DeclPtrTy();
}
+ // C++0x N2914 [namespace.udecl]p6:
+ // A using-declaration shall not name a namespace.
+ if (isa<NamespaceDecl>(ND)) {
+ Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
+ << SS.getRange();
+ return DeclPtrTy();
+ }
+
UsingAlias =
UsingDecl::Create(Context, CurContext, IdentLoc, SS.getRange(),
ND->getLocation(), UsingLoc, ND, NNS, IsTypeName);
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s
+// C++0x N2914.
+
+struct A {
+ template<class T> void f(T);
+ template<class T> struct X { };
+};
+
+struct B : A {
+ using A::f<double>; // expected-error{{using declaration can not refer to template specialization}}
+ using A::X<int>; // expected-error{{using declaration can not refer to template specialization}}
+};
\ No newline at end of file
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s
+// C++0x N2914.
+
+namespace A {
+ namespace B { }
+}
+
+using A::B; // expected-error{{using declaration can not refer to namespace}}
static int a;
};
-using X::i; // expected-error{{error: using declaration refers to class member}}
-using X::s; // expected-error{{error: using declaration refers to class member}}
+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}}
void f() {
- using X::i; // expected-error{{error: using declaration refers to class member}}
- using X::s; // expected-error{{error: using declaration refers to class member}}
+ 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}}
}