[clang] [SemaCXX] Implement CWG2351 `void{}` (PR #78060)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 8 17:38:33 PST 2024


================
@@ -1600,12 +1600,25 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo,
     return ExprError(Diag(TyBeginLoc, diag::err_init_for_function_type)
                        << Ty << FullRange);
 
-  // C++17 [expr.type.conv]p2:
-  //   If the type is cv void and the initializer is (), the expression is a
-  //   prvalue of the specified type that performs no initialization.
-  if (!Ty->isVoidType() &&
-      RequireCompleteType(TyBeginLoc, ElemTy,
-                          diag::err_invalid_incomplete_type_use, FullRange))
+  // C++17 [expr.type.conv]p2, per DR2351:
+  //   If the type is cv void and the initializer is () or {}, the expression is
+  //   a prvalue of the specified type that performs no initialization.
+  if (Ty->isVoidType()) {
----------------
shafik wrote:

I am trying to understand why the check is here, and I think it is b/c the diagnostic is coming from one of these two lines:

```cpp
InitializationSequence InitSeq(*this, Entity, Kind, Exprs);
  ExprResult Result = InitSeq.Perform(*this, Entity, Kind, Exprs);
```

is that correct? So then we need to handle this case before we attempt the initialization sequence. 

https://github.com/llvm/llvm-project/pull/78060


More information about the cfe-commits mailing list