diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-11 17:50:32 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-06-11 17:50:32 +0000 |
commit | 715f7a1bd058c64a39cc4773114dfb46ae8cc8a3 (patch) | |
tree | d9f4369bedcbe50c9dc03ee5498544702d86616e /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | ef2d6d99c0d35e46dce7fff6b999a3a1fc08aecc (diff) | |
download | bcm5719-llvm-715f7a1bd058c64a39cc4773114dfb46ae8cc8a3.tar.gz bcm5719-llvm-715f7a1bd058c64a39cc4773114dfb46ae8cc8a3.zip |
For DR712: store on a DeclRefExpr whether it constitutes an odr-use.
Begin restructuring to support the forms of non-odr-use reference
permitted by DR712.
llvm-svn: 363086
Diffstat (limited to 'clang/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 6c5847ddfcd..d0ff0994ed8 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -285,7 +285,7 @@ static void instantiateOMPDeclareSimdDeclAttr( SmallVector<Expr *, 4> Uniforms, Aligneds, Alignments, Linears, Steps; SmallVector<unsigned, 4> LinModifiers; - auto &&Subst = [&](Expr *E) -> ExprResult { + auto SubstExpr = [&](Expr *E) -> ExprResult { if (auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreParenImpCasts())) if (auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl())) { Sema::ContextRAII SavedContext(S, FD); @@ -300,6 +300,17 @@ static void instantiateOMPDeclareSimdDeclAttr( return S.SubstExpr(E, TemplateArgs); }; + // Substitute a single OpenMP clause, which is a potentially-evaluated + // full-expression. + auto Subst = [&](Expr *E) -> ExprResult { + EnterExpressionEvaluationContext Evaluated( + S, Sema::ExpressionEvaluationContext::PotentiallyEvaluated); + ExprResult Res = SubstExpr(E); + if (Res.isInvalid()) + return Res; + return S.ActOnFinishFullExpr(Res.get(), false); + }; + ExprResult Simdlen; if (auto *E = Attr.getSimdlen()) Simdlen = Subst(E); @@ -4714,8 +4725,12 @@ void Sema::InstantiateVariableDefinition(SourceLocation PointOfInstantiation, // of reference types, [...] explicit instantiation declarations // have the effect of suppressing the implicit instantiation of the entity // to which they refer. + // + // FIXME: That's not exactly the same as "might be usable in constant + // expressions", which only allows constexpr variables and const integral + // types, not arbitrary const literal types. if (TSK == TSK_ExplicitInstantiationDeclaration && - !Var->isUsableInConstantExpressions(getASTContext())) + !Var->mightBeUsableInConstantExpressions(getASTContext())) return; // Make sure to pass the instantiated variable to the consumer at the end. |