本文整理汇总了C++中NamespaceDecl::setInvalidDecl方法的典型用法代码示例。如果您正苦于以下问题:C++ NamespaceDecl::setInvalidDecl方法的具体用法?C++ NamespaceDecl::setInvalidDecl怎么用?C++ NamespaceDecl::setInvalidDecl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamespaceDecl
的用法示例。
在下文中一共展示了NamespaceDecl::setInvalidDecl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
NamespaceDecl *Sema::ActOnRogerNamespaceHeaderPart(DeclContext *DeclContext, IdentifierInfo *II,
SourceLocation IdentLoc,
AttributeList *AttrList) {
// set CurContext
SourceLocation NamespaceLoc;
SourceLocation InlineLoc;
SourceLocation StartLoc = InlineLoc.isValid() ? InlineLoc : NamespaceLoc;
assert(II);
SourceLocation Loc = IdentLoc;
bool IsInline = false;
bool IsInvalid = false;
bool IsStd = false;
bool AddToKnown = false;
//Scope *DeclRegionScope = NamespcScope->getParent();
NamespaceDecl *PrevNS = 0;
// C++ [namespace.def]p2:
// The identifier in an original-namespace-definition shall not
// have been previously defined in the declarative region in
// which the original-namespace-definition appears. The
// identifier in an original-namespace-definition is the name of
// the namespace. Subsequently in that declarative region, it is
// treated as an original-namespace-name.
//
// Since namespace names are unique in their scope, and we don't
// look through using directives, just look for any ordinary names.
const unsigned IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Member |
Decl::IDNS_Type | Decl::IDNS_Using | Decl::IDNS_Tag |
Decl::IDNS_Namespace;
NamedDecl *PrevDecl = 0;
DeclContext::lookup_result R = DeclContext->getRedeclContext()->lookup(II);
for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E;
++I) {
if ((*I)->getIdentifierNamespace() & IDNS) {
PrevDecl = *I;
break;
}
}
PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
if (PrevNS) {
// This is an extended namespace definition.
if (IsInline != PrevNS->isInline()) {
// DiagnoseNamespaceInlineMismatch(*this, NamespaceLoc, Loc, II,
// &IsInline, PrevNS);
assert(false && "need to implement this");
}
return PrevNS;
} else if (PrevDecl) {
// This is an invalid name redefinition.
Diag(Loc, diag::err_redefinition_different_kind)
<< II;
Diag(PrevDecl->getLocation(), diag::note_previous_definition);
IsInvalid = true;
// Continue on to push Namespc as current DeclContext and return it.
} else if (II->isStr("std") &&
DeclContext->getRedeclContext()->isTranslationUnit()) {
// This is the first "real" definition of the namespace "std", so update
// our cache of the "std" namespace to point at this definition.
PrevNS = getStdNamespace();
IsStd = true;
AddToKnown = !IsInline;
} else {
// We've seen this namespace for the first time.
AddToKnown = !IsInline;
}
NamespaceDecl *Namespc = NamespaceDecl::Create(Context, DeclContext, IsInline,
StartLoc, Loc, II, PrevNS);
Namespc->IsRogerNamespace = true;
if (IsInvalid)
Namespc->setInvalidDecl();
//ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
// FIXME: Should we be merging attributes?
if (const VisibilityAttr *Attr = Namespc->getAttr<VisibilityAttr>())
PushNamespaceVisibilityAttr(Attr, Loc);
if (IsStd)
StdNamespace = Namespc;
if (AddToKnown)
KnownNamespaces[Namespc] = false;
DeclContext->addDecl(Namespc);
if (PrevNS) {
return PrevNS;
} else {
return Namespc;
}
}