diff options
author | Larisse Voufo <lvoufo@google.com> | 2014-07-29 18:44:19 +0000 |
---|---|---|
committer | Larisse Voufo <lvoufo@google.com> | 2014-07-29 18:44:19 +0000 |
commit | b6fab26109b0cdca3b83542ec88f6ceb7130ee66 (patch) | |
tree | cdb9a1ed740e501f2327ac0cb885dc04d57cf0b3 /clang/lib/Sema/SemaExpr.cpp | |
parent | b5adb212405905aab3cb037e8316ec04c72ec74d (diff) | |
download | bcm5719-llvm-b6fab26109b0cdca3b83542ec88f6ceb7130ee66.tar.gz bcm5719-llvm-b6fab26109b0cdca3b83542ec88f6ceb7130ee66.zip |
Fix PR10177 where non-type template arguments to alias templates are not marked as used in dependent contexts. The fix actually forces non-dependent names to be checked at template definition time as expected from the standard.
llvm-svn: 214192
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index dbf0f8ef44b..3312f0ccc01 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -12439,6 +12439,8 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, "Invalid Expr argument to DoMarkVarDeclReferenced"); Var->setReferenced(); + TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind(); + // If the context is not potentially evaluated, this is not an odr-use and // does not trigger instantiation. if (!IsPotentiallyEvaluatedContext(SemaRef)) { @@ -12453,25 +12455,26 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, // arguments, where local variables can't be used. const bool RefersToEnclosingScope = (SemaRef.CurContext != Var->getDeclContext() && - Var->getDeclContext()->isFunctionOrMethod() && - Var->hasLocalStorage()); - if (!RefersToEnclosingScope) - return; - - if (LambdaScopeInfo *const LSI = SemaRef.getCurLambda()) { - // If a variable could potentially be odr-used, defer marking it so - // until we finish analyzing the full expression for any lvalue-to-rvalue - // or discarded value conversions that would obviate odr-use. - // Add it to the list of potential captures that will be analyzed - // later (ActOnFinishFullExpr) for eventual capture and odr-use marking - // unless the variable is a reference that was initialized by a constant - // expression (this will never need to be captured or odr-used). - assert(E && "Capture variable should be used in an expression."); - if (!Var->getType()->isReferenceType() || - !IsVariableNonDependentAndAConstantExpression(Var, SemaRef.Context)) - LSI->addPotentialCapture(E->IgnoreParens()); + Var->getDeclContext()->isFunctionOrMethod() && Var->hasLocalStorage()); + if (RefersToEnclosingScope) { + if (LambdaScopeInfo *const LSI = SemaRef.getCurLambda()) { + // If a variable could potentially be odr-used, defer marking it so + // until we finish analyzing the full expression for any + // lvalue-to-rvalue + // or discarded value conversions that would obviate odr-use. + // Add it to the list of potential captures that will be analyzed + // later (ActOnFinishFullExpr) for eventual capture and odr-use marking + // unless the variable is a reference that was initialized by a constant + // expression (this will never need to be captured or odr-used). + assert(E && "Capture variable should be used in an expression."); + if (!Var->getType()->isReferenceType() || + !IsVariableNonDependentAndAConstantExpression(Var, SemaRef.Context)) + LSI->addPotentialCapture(E->IgnoreParens()); + } } - return; + + if (!isTemplateInstantiation(TSK)) + return; } VarTemplateSpecializationDecl *VarSpec = @@ -12483,7 +12486,6 @@ static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, // templates of class templates, and variable template specializations. Delay // instantiations of variable templates, except for those that could be used // in a constant expression. - TemplateSpecializationKind TSK = Var->getTemplateSpecializationKind(); if (isTemplateInstantiation(TSK)) { bool TryInstantiating = TSK == TSK_ImplicitInstantiation; |