[PATCH] D43320: Allow dllimport non-type template arguments in C++17
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 14 16:42:22 PST 2018
rsmith added inline comments.
================
Comment at: clang/lib/AST/ExprConstant.cpp:10166-10182
+ EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
+ Info.IsNonTypeTemplateArgument = true;
+ LValue LV;
+ if (!EvaluateLValue(this, LV, Info) || Result.HasSideEffects ||
+ !CheckLValueConstantExpression(
+ Info, getExprLoc(), Ctx.getLValueReferenceType(getType()), LV))
+ return false;
----------------
rsmith wrote:
> Neither `EM_ConstantFold` nor `EM_IgnoreSideEffects` seem like the right evaluation modes to be using to evaluate a non-type template argument. I would expect `EM_ConstantExpression` to be used for both cases.
Oh, I see, we're allowing side-effects here and then issuing a constant-folding warning elsewhere if there actually were any. *sigh*
I would expect we can get away with not doing that for template arguments. It'd be worth testing whether GCC actually allows constant folding there, or requires a real constant expression.
================
Comment at: clang/lib/Sema/SemaOverload.cpp:5401
- if ((T->isReferenceType()
- ? !Result.get()->EvaluateAsLValue(Eval, S.Context)
- : !Result.get()->EvaluateAsRValue(Eval, S.Context)) ||
+ if (!Result.get()->EvaluateAsNonTypeTemplateArgument(Eval, T, S.Context) ||
(RequireInt && !Eval.Val.isInt())) {
----------------
Don't we get here for `CCEKind`s other than the non-type template argument case?
https://reviews.llvm.org/D43320
More information about the cfe-commits
mailing list