diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-08-20 21:03:30 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-08-20 21:03:30 +0000 |
commit | 6aa46a19c56750e17f7acedc47d95111fd2dcd5d (patch) | |
tree | e34ae427575758352981df5376a2975e2dbcd403 /lib/Sema | |
parent | ffe56ea4c355b82c6fdbed4befc7fe3b956e35a2 (diff) |
Notes
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaCast.cpp | 9 | ||||
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 21 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 |
4 files changed, 30 insertions, 7 deletions
diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp index ba2049d8a606b..d603101c3fd9c 100644 --- a/lib/Sema/SemaCast.cpp +++ b/lib/Sema/SemaCast.cpp @@ -552,7 +552,14 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType, Qualifiers SrcQuals, DestQuals; Self.Context.getUnqualifiedArrayType(UnwrappedSrcType, SrcQuals); Self.Context.getUnqualifiedArrayType(UnwrappedDestType, DestQuals); - + + // We do not meaningfully track object const-ness of Objective-C object + // types. Remove const from the source type if either the source or + // the destination is an Objective-C object type. + if (UnwrappedSrcType->isObjCObjectType() || + UnwrappedDestType->isObjCObjectType()) + SrcQuals.removeConst(); + Qualifiers RetainedSrcQuals, RetainedDestQuals; if (CheckCVR) { RetainedSrcQuals.setCVRQualifiers(SrcQuals.getCVRQualifiers()); diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 91a8c619b26c0..4de7d422072da 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -2401,10 +2401,7 @@ formatBlockPlaceholder(const PrintingPolicy &Policy, const NamedDecl *BlockDecl, static std::string GetDefaultValueString(const ParmVarDecl *Param, const SourceManager &SM, const LangOptions &LangOpts) { - const Expr *defaultArg = Param->getDefaultArg(); - if (!defaultArg) - return ""; - const SourceRange SrcRange = defaultArg->getSourceRange(); + const SourceRange SrcRange = Param->getDefaultArgRange(); CharSourceRange CharSrcRange = CharSourceRange::getTokenRange(SrcRange); bool Invalid = CharSrcRange.isInvalid(); if (Invalid) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 31b24f91c1d93..692a77e2b62fc 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -6999,6 +6999,21 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, return; } } + + if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) { + // A variable can't shadow a local variable in an enclosing scope, if + // they are separated by a non-capturing declaration context. + for (DeclContext *ParentDC = NewDC; + ParentDC && !ParentDC->Equals(OldDC); + ParentDC = getLambdaAwareParentOfDeclContext(ParentDC)) { + // Only block literals, captured statements, and lambda expressions + // can capture; other scopes don't. + if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) && + !isLambdaCallOperator(ParentDC)) { + return; + } + } + } } } @@ -12075,8 +12090,9 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D, FD->setInvalidDecl(); } - // See if this is a redefinition. - if (!FD->isLateTemplateParsed()) { + // See if this is a redefinition. If 'will have body' is already set, then + // these checks were already performed when it was set. + if (!FD->willHaveBody() && !FD->isLateTemplateParsed()) { CheckForFunctionRedefinition(FD, nullptr, SkipBody); // If we're skipping the body, we're done. Don't enter the scope. @@ -13278,6 +13294,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, AddMsStructLayoutForRecord(RD); } } + New->setLexicalDeclContext(CurContext); return New; }; diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index abe912fb548ba..6fee23aa8bc10 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -3771,6 +3771,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, if (PatternDef) { Pattern = PatternDef->getBody(PatternDef); PatternDecl = PatternDef; + if (PatternDef->willHaveBody()) + PatternDef = nullptr; } // FIXME: We need to track the instantiation stack in order to know which |