[PATCH] D99466: Fix PR48889: assertion failure for void() in flattened ternary expression

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 28 11:32:26 PDT 2021


rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/CodeGen/CGExprScalar.cpp:466-469
+    // [expr.type.conv]: if the type is cv void and the initializer is () or {},
+    // the expression is a prvalue of type void that performs no initialization.
+    QualType T = E->getType();
+    return T->isVoidType() ? nullptr : EmitNullValue(T);
----------------
Would it make sense to put this check in `EmitNullValue` instead? That would also cover an `InitListExpr` for `void{}` (which we currently appear to incorrectly reject), and an `ImplicitValueInit` for type `void` (which I don't think can be created legitimately at the moment, but that could just be a failure of imagination on my part).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99466/new/

https://reviews.llvm.org/D99466



More information about the cfe-commits mailing list