aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/clang/AST/DeclBase.h4
-rw-r--r--include/clang/AST/DeclCXX.h55
-rw-r--r--include/clang/AST/DeclNodes.def1
-rw-r--r--include/clang/Basic/DiagnosticParseKinds.td8
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--include/clang/Parse/Action.h9
6 files changed, 79 insertions, 2 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index e2ca1a3298..a2ee895256 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -159,10 +159,12 @@ private:
/// \brief Whether this declaration was "used", meaning that a definition is
/// required.
bool Used : 1;
-
+
+protected:
/// IdentifierNamespace - This specifies what IDNS_* namespace this lives in.
unsigned IdentifierNamespace : 8;
+private:
#ifndef NDEBUG
void CheckAccessDeclContext() const;
#else
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 1216eb09ee..9ca1823f38 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -1049,6 +1049,61 @@ public:
}
static bool classof(const NamespaceAliasDecl *D) { return true; }
};
+
+/// UsingDecl - Represents a C++ using-declaration. For example:
+/// using someNameSpace::someIdentifier;
+class UsingDecl : public NamedDecl {
+
+ /// \brief The source range that covers the nested-name-specifier
+ /// preceding the declaration name.
+ SourceRange NestedNameRange;
+ /// \brief The source location of the target declaration name.
+ SourceLocation TargetNameLocation;
+ /// \brief The source location of the "using" location itself.
+ SourceLocation UsingLocation;
+ /// \brief Target declaration.
+ NamedDecl* TargetDecl;
+ /// \brief Target declaration.
+ NestedNameSpecifier* TargetNestedNameDecl;
+
+ // Had 'typename' keyword.
+ bool IsTypeName;
+
+ UsingDecl(DeclContext *DC, SourceLocation L, SourceRange NNR,
+ SourceLocation TargetNL, SourceLocation UL, NamedDecl* Target,
+ NestedNameSpecifier* TargetNNS, bool IsTypeNameArg)
+ : NamedDecl(Decl::Using, DC, L, Target->getDeclName()),
+ NestedNameRange(NNR), TargetNameLocation(TargetNL),
+ UsingLocation(UL), TargetDecl(Target),
+ TargetNestedNameDecl(TargetNNS), IsTypeName(IsTypeNameArg) {
+ this->IdentifierNamespace = TargetDecl->getIdentifierNamespace();
+ }
+
+public:
+ /// \brief Returns the source range that covers the nested-name-specifier
+ /// preceding the namespace name.
+ SourceRange getNestedNameRange() { return(NestedNameRange); }
+ /// \brief Returns the source location of the target declaration name.
+ SourceLocation getTargetNameLocation() { return(TargetNameLocation); }
+ /// \brief Returns the source location of the "using" location itself.
+ SourceLocation getUsingLocation() { return(UsingLocation); }
+ /// \brief getTargetDecl - Returns target specified by using-decl.
+ NamedDecl *getTargetDecl() { return(TargetDecl); }
+ /// \brief Get target nested name declaration.
+ NestedNameSpecifier* getTargetNestedNameDecl() { return(TargetNestedNameDecl); }
+ /// isTypeName - Return true if using decl had 'typename'.
+ bool isTypeName() const { return(IsTypeName); }
+
+ static UsingDecl *Create(ASTContext &C, DeclContext *DC,
+ SourceLocation L, SourceRange NNR, SourceLocation TargetNL,
+ SourceLocation UL, NamedDecl* Target,
+ NestedNameSpecifier* TargetNNS, bool IsTypeNameArg);
+
+ static bool classof(const Decl *D) {
+ return D->getKind() == Decl::Using;
+ }
+ static bool classof(const UsingDecl *D) { return true; }
+};
/// StaticAssertDecl - Represents a C++0x static_assert declaration.
class StaticAssertDecl : public Decl {
diff --git a/include/clang/AST/DeclNodes.def b/include/clang/AST/DeclNodes.def
index d1b921a4cb..1e4440357b 100644
--- a/include/clang/AST/DeclNodes.def
+++ b/include/clang/AST/DeclNodes.def
@@ -108,6 +108,7 @@ ABSTRACT_DECL(Named, Decl)
DECL(FunctionTemplate, TemplateDecl)
DECL(ClassTemplate, TemplateDecl)
DECL(TemplateTemplateParm, TemplateDecl)
+ DECL(Using, NamedDecl)
DECL(ObjCMethod, NamedDecl)
DECL(ObjCContainer, NamedDecl)
DECL(ObjCCategory, ObjCContainerDecl)
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index ccb59eb51c..d65a97eb70 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -154,6 +154,10 @@ def err_unknown_typename : Error<
"unknown type name %0">;
def err_use_of_tag_name_without_tag : Error<
"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">;
/// Objective-C parser diagnostics
@@ -214,6 +218,8 @@ def ext_ellipsis_exception_spec : Extension<
"exception specification of '...' is a Microsoft extension">;
def err_expected_catch : Error<"expected catch">;
def err_expected_lbrace_or_comma : Error<"expected '{' or ','">;
+def err_using_namespace_in_class : Error<
+ "'using namespace' in class not allowed">;
// C++ derived classes
def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">;
@@ -289,5 +295,5 @@ def warn_pragma_unused_expected_var : Warning<
"expected '#pragma unused' argument to be a variable name">;
def warn_pragma_unused_expected_punc : Warning<
"expected ')' or ',' in '#pragma unused'">;
-
+
} // end of Parser diagnostics
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 855b7b9d29..6bd925797a 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -92,6 +92,10 @@ def warn_use_out_of_scope_declaration : Warning<
"use of out-of-scope declaration of %0">;
def err_inline_non_function : Error<
"'inline' can only appear on functions">;
+def err_using_requires_qualname : Error<
+ "using declaration requires a qualified name">;
+def err_using_typename_non_type : Error<
+ "'typename' keyword used on a non-type">;
def err_invalid_thread : Error<
"'__thread' is only allowed on variable declarations">;
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 47583993bc..5b57521f67 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -932,6 +932,15 @@ public:
IdentifierInfo *Ident) {
return DeclPtrTy();
}
+
+ /// ActOnUsingDirective - This is called when using-directive is parsed.
+ virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope,
+ SourceLocation UsingLoc,
+ const CXXScopeSpec &SS,
+ SourceLocation IdentLoc,
+ IdentifierInfo *TargetName,
+ AttributeList *AttrList,
+ bool IsTypeName);
/// ActOnParamDefaultArgument - Parse default argument for function parameter
virtual void ActOnParamDefaultArgument(DeclPtrTy param,