[clang] [clang][C23] N3006 Underspecified object declarations (PR #79845)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 11:40:50 PDT 2024


================
@@ -7813,6 +7813,32 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
                                            diag::err_variable_object_no_init))
         return ExprError();
     }
+  } else if (LangOpts.C23 &&
----------------
AaronBallman wrote:

I don't think these changes are quite sufficient because I think we need to handle more cases than just compound literals. Consider:
```
constexpr typeof(struct s *) x = 0; // declares `s` which is not an ordinary identifier
constexpr struct S { int a, b; } y = { 0 }; // declares `S`, `a`, and `b`, none of which are ordinary identifiers
constexpr int a = 0, b = 0; // declares `a` and `b` as ordinary identifiers
auto c = (struct T { int x, y; }){0, 0}; // declares `T`, `x`, and `y`, none of which are ordinary identifiers
constexpr int (*fp)(struct X { int x; } val) = 0; // declares `X` and `x` which are not ordinary identifiers
```
(https://godbolt.org/z/Pq87aMnch)

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


More information about the cfe-commits mailing list