Make CXXScopeSpec invalid when incomplete, and propagate that into any

Declarator that depends on it.  This fixes several redundant errors and bad
recoveries.

llvm-svn: 100779
This commit is contained in:
Jeffrey Yasskin 2010-04-08 16:38:48 +00:00
parent af2a317e05
commit c76498d409
20 changed files with 127 additions and 133 deletions

View File

@ -205,7 +205,7 @@ public:
/// \returns the type referred to by this identifier, or NULL if the type
/// does not name an identifier.
virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec *SS = 0,
Scope *S, CXXScopeSpec *SS = 0,
bool isClassName = false,
TypeTy *ObjectType = 0) = 0;
@ -243,7 +243,7 @@ public:
virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
SourceLocation IILoc,
Scope *S,
const CXXScopeSpec *SS,
CXXScopeSpec *SS,
TypeTy *&SuggestedType) {
return false;
}
@ -281,7 +281,7 @@ public:
///
/// \returns the kind of template that this name refers to.
virtual TemplateNameKind isTemplateName(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectType,
bool EnteringContext,
@ -329,7 +329,7 @@ public:
/// This actual is used in the parsing of pseudo-destructor names to
/// distinguish a nested-name-specifier and a "type-name ::" when we
/// see the token sequence "X :: ~".
virtual bool isNonTypeNestedNameSpecifier(Scope *S, const CXXScopeSpec &SS,
virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
SourceLocation IdLoc,
IdentifierInfo &II,
TypeTy *ObjectType) {
@ -371,7 +371,7 @@ public:
///
/// \returns a CXXScopeTy* object representing the C++ scope.
virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
@ -387,7 +387,7 @@ public:
///
/// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
virtual bool IsInvalidUnlessNestedName(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo &II,
TypeTy *ObjectType,
bool EnteringContext) {
@ -428,7 +428,7 @@ public:
/// ActOnCXXExitDeclaratorScope is called.
/// The 'SS' should be a non-empty valid CXXScopeSpec.
/// \returns true if an error occurred, false otherwise.
virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS) {
return false;
}
@ -655,7 +655,7 @@ public:
///
/// \returns the declaration to which this tag refers.
virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
SourceLocation KWLoc, CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
MultiTemplateParamsArg TemplateParameterLists,
@ -1049,7 +1049,7 @@ public:
/// id-expression or identifier was an ampersand ('&'), indicating that
/// we will be taking the address of this expression.
virtual OwningExprResult ActOnIdExpression(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
bool HasTrailingLParen,
bool IsAddressOfOperand) {
@ -1127,7 +1127,7 @@ public:
virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Member,
DeclPtrTy ObjCImpDecl,
bool HasTrailingLParen) {
@ -1315,7 +1315,7 @@ public:
virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
SourceLocation UsingLoc,
SourceLocation NamespcLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *NamespcName,
AttributeList *AttrList);
@ -1326,7 +1326,7 @@ public:
SourceLocation NamespaceLoc,
SourceLocation AliasLoc,
IdentifierInfo *Alias,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *Ident) {
return DeclPtrTy();
@ -1372,7 +1372,7 @@ public:
AccessSpecifier AS,
bool HasUsingKeyword,
SourceLocation UsingLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
AttributeList *AttrList,
bool IsTypeName,
@ -1501,7 +1501,7 @@ public:
/// \returns the type being destructed.
virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec &SS,
Scope *S, CXXScopeSpec &SS,
TypeTy *ObjectType,
bool EnteringContext) {
return getTypeName(II, NameLoc, S, &SS, false, ObjectType);
@ -1683,7 +1683,7 @@ public:
virtual OwningExprResult ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &FirstTypeName,
SourceLocation CCLoc,
SourceLocation TildeLoc,
@ -1729,7 +1729,7 @@ public:
virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorDecl,
Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo *MemberOrBase,
TypeTy *TemplateTypeTy,
SourceLocation IdLoc,
@ -1939,7 +1939,7 @@ public:
/// \param EnteringContext whether we are entering the context of this
/// template.
virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectType,
bool EnteringContext) {
@ -1995,7 +1995,7 @@ public:
virtual DeclResult
ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
TemplateTy Template,
SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc,
@ -2133,7 +2133,7 @@ public:
SourceLocation TemplateLoc,
unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo *Name,
SourceLocation NameLoc,
AttributeList *Attr) {
@ -2581,7 +2581,7 @@ public:
///
/// \parame EnteringContext whether we're entering the context of this
/// scope specifier.
virtual void CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS,
virtual void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
bool EnteringContext) { }
/// \brief Code completion for a C++ "using" declaration or directive.
@ -2863,7 +2863,7 @@ public:
/// \returns the type referred to by this identifier, or NULL if the type
/// does not name an identifier.
virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec *SS,
Scope *S, CXXScopeSpec *SS,
bool isClassName = false,
TypeTy *ObjectType = 0);
@ -2873,7 +2873,7 @@ public:
const CXXScopeSpec *SS);
virtual TemplateNameKind isTemplateName(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectType,
bool EnteringContext,

View File

@ -1354,7 +1354,7 @@ private:
//===--------------------------------------------------------------------===//
// C++ 9: classes [class] and C structs/unions.
TypeResult ParseClassName(SourceLocation &EndLocation,
const CXXScopeSpec *SS = 0);
CXXScopeSpec *SS = 0);
void ParseClassSpecifier(tok::TokenKind TagTokKind, SourceLocation TagLoc,
DeclSpec &DS,
const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo(),

View File

@ -197,7 +197,7 @@ namespace {
}
virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
SourceLocation KWLoc, CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
MultiTemplateParamsArg TemplateParameterLists,

View File

@ -30,7 +30,7 @@ Action::~Action() {}
Action::DeclPtrTy Action::ActOnUsingDirective(Scope *CurScope,
SourceLocation UsingLoc,
SourceLocation NamespcLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *NamespcName,
AttributeList *AttrList) {
@ -47,7 +47,7 @@ Action::DeclPtrTy Action::ActOnUsingDeclaration(Scope *CurScope,
AccessSpecifier AS,
bool HasUsingKeyword,
SourceLocation UsingLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
AttributeList *AttrList,
bool IsTypeName,
@ -144,7 +144,7 @@ void MinimalAction::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
/// FIXME: Use the passed CXXScopeSpec for accurate C++ type checking.
Action::TypeTy *
MinimalAction::getTypeName(IdentifierInfo &II, SourceLocation Loc,
Scope *S, const CXXScopeSpec *SS,
Scope *S, CXXScopeSpec *SS,
bool isClassName, TypeTy *ObjectType) {
if (TypeNameInfo *TI = II.getFETokenInfo<TypeNameInfo>())
if (TI->isTypeName)
@ -161,7 +161,7 @@ bool MinimalAction::isCurrentClassName(const IdentifierInfo &, Scope *,
TemplateNameKind
MinimalAction::isTemplateName(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectType,
bool EnteringScope,

View File

@ -2583,20 +2583,18 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
if (getLang().CPlusPlus && D.mayHaveIdentifier()) {
// ParseDeclaratorInternal might already have parsed the scope.
bool afterCXXScope = D.getCXXScopeSpec().isSet();
if (!afterCXXScope) {
if (D.getCXXScopeSpec().isEmpty()) {
ParseOptionalCXXScopeSpecifier(D.getCXXScopeSpec(), /*ObjectType=*/0,
true);
afterCXXScope = D.getCXXScopeSpec().isSet();
}
if (afterCXXScope) {
if (D.getCXXScopeSpec().isValid()) {
if (Actions.ShouldEnterDeclaratorScope(CurScope, D.getCXXScopeSpec()))
// Change the declaration context for name lookup, until this function
// is exited (and the declarator has been parsed).
DeclScopeObj.EnterDeclaratorScope();
}
}
if (Tok.is(tok::identifier) || Tok.is(tok::kw_operator) ||
Tok.is(tok::annot_template_id) || Tok.is(tok::tilde)) {
// We found something that indicates the start of an unqualified-id.
@ -2612,7 +2610,10 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
/*AllowDestructorName=*/true,
AllowConstructorName,
/*ObjectType=*/0,
D.getName())) {
D.getName()) ||
// Once we're past the identifier, if the scope was bad, mark the
// whole declarator bad.
D.getCXXScopeSpec().isInvalid()) {
D.SetIdentifier(0, Tok.getLocation());
D.setInvalidType(true);
} else {

View File

@ -465,7 +465,7 @@ void Parser::ParseDecltypeSpecifier(DeclSpec &DS) {
/// simple-template-id
///
Parser::TypeResult Parser::ParseClassName(SourceLocation &EndLocation,
const CXXScopeSpec *SS) {
CXXScopeSpec *SS) {
// Check whether we have a template-id that names a type.
if (Tok.is(tok::annot_template_id)) {
TemplateIdAnnotation *TemplateId

View File

@ -758,14 +758,14 @@ public:
DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr);
virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec *SS,
Scope *S, CXXScopeSpec *SS,
bool isClassName = false,
TypeTy *ObjectType = 0);
virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S);
virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
SourceLocation IILoc,
Scope *S,
const CXXScopeSpec *SS,
CXXScopeSpec *SS,
TypeTy *&SuggestedType);
virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) {
@ -877,7 +877,7 @@ public:
const IdentifierInfo &Name);
virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
SourceLocation KWLoc, CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
MultiTemplateParamsArg TemplateParameterLists,
@ -1407,7 +1407,7 @@ public:
bool AllowBuiltinCreation = false);
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
bool InUnqualifiedLookup = false);
bool LookupParsedName(LookupResult &R, Scope *S, const CXXScopeSpec *SS,
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
bool AllowBuiltinCreation = false,
bool EnteringContext = false);
ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II);
@ -1425,7 +1425,7 @@ public:
void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
VisibleDeclConsumer &Consumer);
bool CorrectTypo(LookupResult &R, Scope *S, const CXXScopeSpec *SS,
bool CorrectTypo(LookupResult &R, Scope *S, CXXScopeSpec *SS,
DeclContext *MemberContext = 0,
bool EnteringContext = false,
const ObjCObjectPointerType *OPT = 0);
@ -1719,12 +1719,12 @@ public:
virtual SourceRange getExprRange(ExprTy *E) const;
virtual OwningExprResult ActOnIdExpression(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
bool HasTrailingLParen,
bool IsAddressOfOperand);
bool DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS, LookupResult &R);
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R);
OwningExprResult LookupInObjCMethod(LookupResult &R,
Scope *S,
@ -1758,7 +1758,7 @@ public:
const LookupResult &R,
bool HasTrailingLParen);
OwningExprResult BuildQualifiedDeclarationNameExpr(const CXXScopeSpec &SS,
OwningExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
DeclarationName Name,
SourceLocation NameLoc);
OwningExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
@ -1828,7 +1828,7 @@ public:
QualType BaseType,
SourceLocation OpLoc,
bool IsArrow,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
NamedDecl *FirstQualifierInScope,
DeclarationName Name,
SourceLocation NameLoc,
@ -1844,7 +1844,7 @@ public:
OwningExprResult LookupMemberExpr(LookupResult &R, Expr *&Base,
bool &IsArrow, SourceLocation OpLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
DeclPtrTy ObjCImpDecl);
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
@ -1864,7 +1864,7 @@ public:
virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Member,
DeclPtrTy ObjCImpDecl,
bool HasTrailingLParen);
@ -2008,7 +2008,7 @@ public:
virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
SourceLocation UsingLoc,
SourceLocation NamespcLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *NamespcName,
AttributeList *AttrList);
@ -2019,7 +2019,7 @@ public:
SourceLocation NamespaceLoc,
SourceLocation AliasLoc,
IdentifierInfo *Alias,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *Ident);
@ -2040,7 +2040,7 @@ public:
NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
SourceLocation UsingLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
DeclarationName Name,
AttributeList *AttrList,
@ -2052,7 +2052,7 @@ public:
AccessSpecifier AS,
bool HasUsingKeyword,
SourceLocation UsingLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
AttributeList *AttrList,
bool IsTypeName,
@ -2153,7 +2153,7 @@ public:
virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec &SS,
Scope *S, CXXScopeSpec &SS,
TypeTy *ObjectType,
bool EnteringContext);
@ -2287,7 +2287,7 @@ public:
virtual OwningExprResult ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &FirstTypeName,
SourceLocation CCLoc,
SourceLocation TildeLoc,
@ -2303,7 +2303,8 @@ public:
virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
bool RequireCompleteDeclContext(const CXXScopeSpec &SS);
// Marks SS invalid if it represents an incomplete type.
bool RequireCompleteDeclContext(CXXScopeSpec &SS);
DeclContext *computeDeclContext(QualType T);
DeclContext *computeDeclContext(const CXXScopeSpec &SS,
@ -2320,13 +2321,13 @@ public:
bool isAcceptableNestedNameSpecifier(NamedDecl *SD);
NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
virtual bool isNonTypeNestedNameSpecifier(Scope *S, const CXXScopeSpec &SS,
virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
SourceLocation IdLoc,
IdentifierInfo &II,
TypeTy *ObjectType);
CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
@ -2336,7 +2337,7 @@ public:
bool ErrorRecoveryLookup);
virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
@ -2344,7 +2345,7 @@ public:
bool EnteringContext);
virtual bool IsInvalidUnlessNestedName(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo &II,
TypeTy *ObjectType,
bool EnteringContext);
@ -2371,7 +2372,7 @@ public:
/// looked up in the declarator-id's scope, until the declarator is parsed and
/// ActOnCXXExitDeclaratorScope is called.
/// The 'SS' should be a non-empty valid CXXScopeSpec.
virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
/// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
/// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
@ -2452,7 +2453,7 @@ public:
virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,
Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo *MemberOrBase,
TypeTy *TemplateTypeTy,
SourceLocation IdLoc,
@ -2690,11 +2691,11 @@ public:
//===--------------------------------------------------------------------===//
// C++ Templates [C++ 14]
//
void LookupTemplateName(LookupResult &R, Scope *S, const CXXScopeSpec &SS,
void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
QualType ObjectType, bool EnteringContext);
virtual TemplateNameKind isTemplateName(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectType,
bool EnteringContext,
@ -2767,7 +2768,7 @@ public:
bool &IsExplicitSpecialization);
DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
SourceLocation KWLoc, CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr,
TemplateParameterList *TemplateParams,
@ -2795,13 +2796,13 @@ public:
LookupResult &R,
bool RequiresADL,
const TemplateArgumentListInfo &TemplateArgs);
OwningExprResult BuildQualifiedTemplateIdExpr(const CXXScopeSpec &SS,
OwningExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
DeclarationName Name,
SourceLocation NameLoc,
const TemplateArgumentListInfo &TemplateArgs);
virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectType,
bool EnteringContext);
@ -2814,7 +2815,7 @@ public:
virtual DeclResult
ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
TemplateTy Template,
SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc,
@ -2868,7 +2869,7 @@ public:
SourceLocation TemplateLoc,
unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo *Name,
SourceLocation NameLoc,
AttributeList *Attr);
@ -4265,7 +4266,7 @@ public:
virtual void CodeCompleteCase(Scope *S);
virtual void CodeCompleteCall(Scope *S, ExprTy *Fn,
ExprTy **Args, unsigned NumArgs);
virtual void CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS,
virtual void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
bool EnteringContext);
virtual void CodeCompleteUsing(Scope *S);
virtual void CodeCompleteUsingDirective(Scope *S);

View File

@ -230,7 +230,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) {
/// that is currently being defined. Or, if we have a type that names
/// a class template specialization that is not a complete type, we
/// will attempt to instantiate that class template.
bool Sema::RequireCompleteDeclContext(const CXXScopeSpec &SS) {
bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS) {
if (!SS.isSet() || SS.isInvalid())
return false;
@ -247,10 +247,13 @@ bool Sema::RequireCompleteDeclContext(const CXXScopeSpec &SS) {
return false;
// The type must be complete.
return RequireCompleteType(SS.getRange().getBegin(),
Context.getTypeDeclType(Tag),
PDiag(diag::err_incomplete_nested_name_spec)
<< SS.getRange());
if (RequireCompleteType(SS.getRange().getBegin(),
Context.getTypeDeclType(Tag),
PDiag(diag::err_incomplete_nested_name_spec)
<< SS.getRange())) {
SS.setScopeRep(0); // Mark the ScopeSpec invalid.
return true;
}
}
return false;
@ -322,7 +325,7 @@ NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) {
return 0;
}
bool Sema::isNonTypeNestedNameSpecifier(Scope *S, const CXXScopeSpec &SS,
bool Sema::isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
SourceLocation IdLoc,
IdentifierInfo &II,
TypeTy *ObjectTypePtr) {
@ -384,7 +387,7 @@ bool Sema::isNonTypeNestedNameSpecifier(Scope *S, const CXXScopeSpec &SS,
/// scope if it *knows* that the result is correct. It should not return in a
/// dependent context, for example.
Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
@ -593,7 +596,7 @@ Sema::CXXScopeTy *Sema::BuildCXXNestedNameSpecifier(Scope *S,
/// 'CCLoc' is the location of '::' and 'II' is the identifier for 'bar'.
/// Returns a CXXScopeTy* object representing the C++ scope.
Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdLoc,
SourceLocation CCLoc,
IdentifierInfo &II,
@ -611,7 +614,7 @@ Sema::CXXScopeTy *Sema::ActOnCXXNestedNameSpecifier(Scope *S,
/// conservatively correct to always return false from this method.
///
/// The arguments are the same as those passed to ActOnCXXNestedNameSpecifier.
bool Sema::IsInvalidUnlessNestedName(Scope *S, const CXXScopeSpec &SS,
bool Sema::IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS,
IdentifierInfo &II, TypeTy *ObjectType,
bool EnteringContext) {
return BuildCXXNestedNameSpecifier(S, SS, SourceLocation(), SourceLocation(),
@ -676,7 +679,7 @@ bool Sema::ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
/// looked up in the declarator-id's scope, until the declarator is parsed and
/// ActOnCXXExitDeclaratorScope is called.
/// The 'SS' should be a non-empty valid CXXScopeSpec.
bool Sema::ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS) {
bool Sema::ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS) {
assert(SS.isSet() && "Parser passed invalid CXXScopeSpec.");
if (SS.isInvalid()) return true;

View File

@ -2266,7 +2266,7 @@ void Sema::CodeCompleteCall(Scope *S, ExprTy *FnIn,
Results.size());
}
void Sema::CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS,
void Sema::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
bool EnteringContext) {
if (!SS.getScopeRep() || !CodeCompleter)
return;

View File

@ -61,7 +61,7 @@ Sema::DeclGroupPtrTy Sema::ConvertDeclToDeclGroup(DeclPtrTy Ptr) {
/// If name lookup results in an ambiguity, this routine will complain
/// and then return NULL.
Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
Scope *S, const CXXScopeSpec *SS,
Scope *S, CXXScopeSpec *SS,
bool isClassName,
TypeTy *ObjectTypePtr) {
// Determine where we will perform name lookup.
@ -236,7 +236,7 @@ DeclSpec::TST Sema::isTagName(IdentifierInfo &II, Scope *S) {
bool Sema::DiagnoseUnknownTypeName(const IdentifierInfo &II,
SourceLocation IILoc,
Scope *S,
const CXXScopeSpec *SS,
CXXScopeSpec *SS,
TypeTy *&SuggestedType) {
// We don't have anything to suggest (yet).
SuggestedType = 0;
@ -4707,7 +4707,7 @@ bool Sema::isAcceptableTagRedeclaration(const TagDecl *Previous,
/// TagSpec indicates what kind of tag this is. TUK indicates whether this is a
/// reference/declaration/definition of a tag.
Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
SourceLocation KWLoc, CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr, AccessSpecifier AS,
MultiTemplateParamsArg TemplateParameterLists,

View File

@ -1013,7 +1013,7 @@ static bool FindBaseInitializer(Sema &SemaRef,
Sema::MemInitResult
Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo *MemberOrBase,
TypeTy *TemplateTypeTy,
SourceLocation IdLoc,
@ -3013,7 +3013,7 @@ void Sema::ActOnFinishNamespaceDef(DeclPtrTy D, SourceLocation RBrace) {
Sema::DeclPtrTy Sema::ActOnUsingDirective(Scope *S,
SourceLocation UsingLoc,
SourceLocation NamespcLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *NamespcName,
AttributeList *AttrList) {
@ -3082,7 +3082,7 @@ Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,
AccessSpecifier AS,
bool HasUsingKeyword,
SourceLocation UsingLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
AttributeList *AttrList,
bool IsTypeName,
@ -3363,7 +3363,7 @@ void Sema::HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow) {
/// the lookup differently for these declarations.
NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
SourceLocation UsingLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
DeclarationName Name,
AttributeList *AttrList,
@ -3700,7 +3700,7 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
SourceLocation NamespaceLoc,
SourceLocation AliasLoc,
IdentifierInfo *Alias,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
SourceLocation IdentLoc,
IdentifierInfo *Ident) {

View File

@ -895,7 +895,7 @@ static void DiagnoseInstanceReference(Sema &SemaRef,
/// Diagnose an empty lookup.
///
/// \return false if new lookup candidates were found
bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS,
bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS,
LookupResult &R) {
DeclarationName Name = R.getLookupName();
@ -1001,7 +1001,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS,
}
Sema::OwningExprResult Sema::ActOnIdExpression(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Id,
bool HasTrailingLParen,
bool isAddressOfOperand) {
@ -1200,7 +1200,7 @@ Sema::BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
/// There's a large number of things which don't need to be done along
/// this path.
Sema::OwningExprResult
Sema::BuildQualifiedDeclarationNameExpr(const CXXScopeSpec &SS,
Sema::BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
DeclarationName Name,
SourceLocation NameLoc) {
DeclContext *DC;
@ -2549,7 +2549,7 @@ bool Sema::CheckQualifiedMemberReference(Expr *BaseExpr,
static bool
LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
SourceRange BaseRange, const RecordType *RTy,
SourceLocation OpLoc, const CXXScopeSpec &SS) {
SourceLocation OpLoc, CXXScopeSpec &SS) {
RecordDecl *RDecl = RTy->getDecl();
if (SemaRef.RequireCompleteType(OpLoc, QualType(RTy, 0),
SemaRef.PDiag(diag::err_typecheck_incomplete_tag)
@ -2606,7 +2606,7 @@ LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
Sema::OwningExprResult
Sema::BuildMemberReferenceExpr(ExprArg BaseArg, QualType BaseType,
SourceLocation OpLoc, bool IsArrow,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
NamedDecl *FirstQualifierInScope,
DeclarationName Name, SourceLocation NameLoc,
const TemplateArgumentListInfo *TemplateArgs) {
@ -2841,7 +2841,7 @@ Sema::BuildMemberReferenceExpr(ExprArg Base, QualType BaseExprType,
Sema::OwningExprResult
Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
bool &IsArrow, SourceLocation OpLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
DeclPtrTy ObjCImpDecl) {
assert(BaseExpr && "no base expression");
@ -3279,7 +3279,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr,
Sema::OwningExprResult Sema::ActOnMemberAccessExpr(Scope *S, ExprArg BaseArg,
SourceLocation OpLoc,
tok::TokenKind OpKind,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Id,
DeclPtrTy ObjCImpDecl,
bool HasTrailingLParen) {

View File

@ -29,7 +29,7 @@ using namespace clang;
Action::TypeTy *Sema::getDestructorName(SourceLocation TildeLoc,
IdentifierInfo &II,
SourceLocation NameLoc,
Scope *S, const CXXScopeSpec &SS,
Scope *S, CXXScopeSpec &SS,
TypeTy *ObjectTypePtr,
bool EnteringContext) {
// Determine where to perform name lookup.
@ -2705,7 +2705,7 @@ Sema::OwningExprResult Sema::BuildPseudoDestructorExpr(ExprArg Base,
Sema::OwningExprResult Sema::ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &FirstTypeName,
SourceLocation CCLoc,
SourceLocation TildeLoc,

View File

@ -1291,7 +1291,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
/// context of the scope-specifier SS (if present).
///
/// @returns True if any decls were found (but possibly ambiguous)
bool Sema::LookupParsedName(LookupResult &R, Scope *S, const CXXScopeSpec *SS,
bool Sema::LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
bool AllowBuiltinCreation, bool EnteringContext) {
if (SS && SS->isInvalid()) {
// When the scope specifier is invalid, don't even look for
@ -2500,7 +2500,7 @@ void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding,
/// \returns true if the typo was corrected, in which case the \p Res
/// structure will contain the results of name lookup for the
/// corrected name. Otherwise, returns false.
bool Sema::CorrectTypo(LookupResult &Res, Scope *S, const CXXScopeSpec *SS,
bool Sema::CorrectTypo(LookupResult &Res, Scope *S, CXXScopeSpec *SS,
DeclContext *MemberContext, bool EnteringContext,
const ObjCObjectPointerType *OPT) {
if (Diags.hasFatalErrorOccurred())

View File

@ -76,7 +76,7 @@ static void FilterAcceptableTemplateNames(ASTContext &C, LookupResult &R) {
}
TemplateNameKind Sema::isTemplateName(Scope *S,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectTypePtr,
bool EnteringContext,
@ -169,7 +169,7 @@ bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II,
}
void Sema::LookupTemplateName(LookupResult &Found,
Scope *S, const CXXScopeSpec &SS,
Scope *S, CXXScopeSpec &SS,
QualType ObjectType,
bool EnteringContext) {
// Determine where to perform name lookup
@ -705,7 +705,7 @@ static void SetNestedNameSpecifier(TagDecl *T, const CXXScopeSpec &SS) {
Sema::DeclResult
Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
SourceLocation KWLoc, const CXXScopeSpec &SS,
SourceLocation KWLoc, CXXScopeSpec &SS,
IdentifierInfo *Name, SourceLocation NameLoc,
AttributeList *Attr,
TemplateParameterList *TemplateParams,
@ -1545,7 +1545,7 @@ Sema::OwningExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
// We actually only call this from template instantiation.
Sema::OwningExprResult
Sema::BuildQualifiedTemplateIdExpr(const CXXScopeSpec &SS,
Sema::BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
DeclarationName Name,
SourceLocation NameLoc,
const TemplateArgumentListInfo &TemplateArgs) {
@ -1586,7 +1586,7 @@ Sema::BuildQualifiedTemplateIdExpr(const CXXScopeSpec &SS,
/// of the "template" keyword, and "apply" is the \p Name.
Sema::TemplateTy
Sema::ActOnDependentTemplateName(SourceLocation TemplateKWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
UnqualifiedId &Name,
TypeTy *ObjectType,
bool EnteringContext) {
@ -3482,7 +3482,7 @@ Sema::DeclResult
Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
TagUseKind TUK,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
TemplateTy TemplateD,
SourceLocation TemplateNameLoc,
SourceLocation LAngleLoc,
@ -4663,7 +4663,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
SourceLocation TemplateLoc,
unsigned TagSpec,
SourceLocation KWLoc,
const CXXScopeSpec &SS,
CXXScopeSpec &SS,
IdentifierInfo *Name,
SourceLocation NameLoc,
AttributeList *Attr) {

View File

@ -8,12 +8,11 @@ template void f0(int); // okay
// A definition of the class or class template containing a member function
// template shall be in scope at the point of the explicit instantiation of
// the member function template.
struct X0; // expected-note 3{{forward declaration}}
template<typename> struct X1; // expected-note 8{{declared here}}
struct X0; // expected-note {{forward declaration}}
template<typename> struct X1; // expected-note 5{{declared here}}
// FIXME: Repeated diagnostics here!
template void X0::f0<int>(int); // expected-error 3{{incomplete type}} // expected-error{{invalid token after top level declarator}}
template void X1<int>::f0<int>(int); // expected-error 3{{implicit instantiation of undefined template}} // expected-error{{invalid token after top level declarator}}
template void X0::f0<int>(int); // expected-error {{incomplete type}}
template void X1<int>::f0<int>(int); // expected-error {{implicit instantiation of undefined template}}
// A definition of a class template or class member template shall be in scope
// at the point of the explicit instantiation of the class template or class
@ -33,11 +32,10 @@ template struct X2<int>::Inner<float>; // expected-error{{explicit instantiation
// A definition of a class template shall be in scope at the point of an
// explicit instantiation of a member function or a static data member of the
// class template.
template void X1<int>::f1(int); // expected-error 2{{undefined template}} \
// expected-error{{does not refer}}
template void X1<int>::f1(int); // expected-error {{undefined template}}
template void X1<int>::f1<int>(int); // expected-error {{undefined template}}
template int X1<int>::member; // expected-error 2{{undefined template}} \
// expected-error{{does not refer}}
template int X1<int>::member; // expected-error {{undefined template}}
// A definition of a member class of a class template shall be in scope at the
// point of an explicit instantiation of the member class.

View File

@ -165,8 +165,7 @@ void ::global_func2(int) { } // expected-error{{definition or redeclaration of '
void N::f() { } // okay
struct Y; // expected-note{{forward declaration of 'Y'}}
Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}} \
// expected-error{{no type named 'foo' in}}
Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}}
X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} \
// expected-error{{C++ requires a type specifier for all declarations}} \
@ -224,9 +223,8 @@ namespace test2 {
// PR6259, invalid case
namespace test3 {
// FIXME: this should really only trigger once
class A; // expected-note 2 {{forward declaration}}
class A; // expected-note {{forward declaration}}
void foo(const char *path) {
A::execute(path); // expected-error 2 {{incomplete type 'test3::A' named in nested name specifier}}
A::execute(path); // expected-error {{incomplete type 'test3::A' named in nested name specifier}}
}
}

View File

@ -29,8 +29,7 @@ template < typename TT > struct ForwardIterator : I
typedef instantiate< & requirement_<void(*)(usage_requirements<ForwardIterator> x)>::failed> boost_concept_check2; // expected-note 2 {{in instantiation}}
};
typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX; // expected-error{{no member named}} \
// expected-note 6{{in instantiation}}
typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX;// expected-note 6{{in instantiation}}
template<typename T> struct X0 { };
template<typename R, typename A1> struct X0<R(A1 param)> { };

View File

@ -11,6 +11,5 @@ add_pointer<float>::type test2(int * ptr) {
return ptr; // expected-error{{cannot initialize return object of type 'add_pointer<float>::type' (aka 'float *') with an lvalue of type 'int *'}}
}
add_pointer<int&>::type // expected-note{{in instantiation of template class 'add_pointer<int &>' requested here}} \
// expected-error {{no type named 'type' in 'add_pointer<int &>'}}
add_pointer<int&>::type // expected-note{{in instantiation of template class 'add_pointer<int &>' requested here}}
test3();

View File

@ -42,13 +42,10 @@ namespace N {
}
N::X<N::A>::type *ip4 = &i;
N::X<N::B>::type *ip5 = &i; // expected-note{{in instantiation of template class 'N::X<N::B>' requested here}} \
// expected-error{{no type named 'type' in}}
N::X<N::C>::type *ip6 = &i; // expected-note{{in instantiation of template class 'N::X<N::C>' requested here}} \
// expected-error{{no type named 'type' in}}
N::X<N::B>::type *ip5 = &i; // expected-note{{in instantiation of template class 'N::X<N::B>' requested here}}
N::X<N::C>::type *ip6 = &i; // expected-note{{in instantiation of template class 'N::X<N::C>' requested here}}
N::X<int>::type fail1; // expected-note{{in instantiation of template class 'N::X<int>' requested here}} \
// expected-error{{no type named 'type' in}}
N::X<int>::type fail1; // expected-note{{in instantiation of template class 'N::X<int>' requested here}}
template<typename T>
struct Y {
@ -69,7 +66,5 @@ struct C {
};
::Y<A>::type ip7 = &i;
::Y<B>::type ip8 = &i; // expected-note{{in instantiation of template class 'Y<B>' requested here}} \
// expected-error{{no type named 'type' in}}
::Y<C>::type ip9 = &i; // expected-note{{in instantiation of template class 'Y<C>' requested here}} \
// expected-error{{no type named 'type' in}}
::Y<B>::type ip8 = &i; // expected-note{{in instantiation of template class 'Y<B>' requested here}}
::Y<C>::type ip9 = &i; // expected-note{{in instantiation of template class 'Y<C>' requested here}}