diff options
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/DeclSpec.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 37 |
3 files changed, 39 insertions, 4 deletions
diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 18ecf9ef52..2fb4f35cd8 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -151,6 +151,9 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, + SourceLocation ConstQualifierLoc, + SourceLocation + VolatileQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, @@ -177,6 +180,8 @@ DeclaratorChunk DeclaratorChunk::getFunction(bool hasProto, bool isVariadic, I.Fun.ArgInfo = 0; I.Fun.RefQualifierIsLValueRef = RefQualifierIsLvalueRef; I.Fun.RefQualifierLoc = RefQualifierLoc.getRawEncoding(); + I.Fun.ConstQualifierLoc = ConstQualifierLoc.getRawEncoding(); + I.Fun.VolatileQualifierLoc = VolatileQualifierLoc.getRawEncoding(); I.Fun.MutableLoc = MutableLoc.getRawEncoding(); I.Fun.ExceptionSpecType = ESpecType; I.Fun.ExceptionSpecLoc = ESpecLoc.getRawEncoding(); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 8d993ef610..8cadec5f89 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -7222,6 +7222,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, Declarator D(DS, Declarator::BlockContext); D.AddTypeInfo(DeclaratorChunk::getFunction(false, false, SourceLocation(), 0, 0, 0, true, SourceLocation(), + SourceLocation(), SourceLocation(), SourceLocation(), EST_None, SourceLocation(), 0, 0, 0, 0, Loc, Loc, D), diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index f3a705f93e..f828b144d6 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -555,6 +555,8 @@ static void maybeSynthesizeBlockSignature(TypeProcessingState &state, /*args*/ 0, 0, /*type quals*/ 0, /*ref-qualifier*/true, SourceLocation(), + /*const qualifier*/SourceLocation(), + /*volatile qualifier*/SourceLocation(), /*mutable qualifier*/SourceLocation(), /*EH*/ EST_None, SourceLocation(), 0, 0, 0, 0, /*parens*/ loc, loc, @@ -2431,10 +2433,37 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, << Quals; } else { if (FnTy->getTypeQuals() != 0) { - if (D.isFunctionDeclarator()) - S.Diag(D.getIdentifierLoc(), - diag::err_invalid_qualified_function_type); - else + if (D.isFunctionDeclarator()) { + SourceRange Range = D.getIdentifierLoc(); + for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) { + const DeclaratorChunk &Chunk = D.getTypeObject(N-I-1); + if (Chunk.Kind == DeclaratorChunk::Function && + Chunk.Fun.TypeQuals != 0) { + switch (Chunk.Fun.TypeQuals) { + case Qualifiers::Const: + Range = Chunk.Fun.getConstQualifierLoc(); + break; + case Qualifiers::Volatile: + Range = Chunk.Fun.getVolatileQualifierLoc(); + break; + case Qualifiers::Const | Qualifiers::Volatile: { + SourceLocation CLoc = Chunk.Fun.getConstQualifierLoc(); + SourceLocation VLoc = Chunk.Fun.getVolatileQualifierLoc(); + if (S.getSourceManager() + .isBeforeInTranslationUnit(CLoc, VLoc)) { + Range = SourceRange(CLoc, VLoc); + } else { + Range = SourceRange(VLoc, CLoc); + } + } + break; + } + break; + } + } + S.Diag(Range.getBegin(), diag::err_invalid_qualified_function_type) + << FixItHint::CreateRemoval(Range); + } else S.Diag(D.getIdentifierLoc(), diag::err_invalid_qualified_typedef_function_type_use) << FreeFunction; |