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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D43320: A... Reid Kleckner via Phabricator via cfe-commits
    • [PATCH] D433... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D433... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D433... Reid Kleckner via Phabricator via cfe-commits
    • [PATCH] D433... Reid Kleckner via Phabricator via cfe-commits
    • [PATCH] D433... Richard Smith - zygoloid via Phabricator via cfe-commits

Reply via email to