================
@@ -85,3 +85,33 @@ void func() {
   static const int b; // zero-init-var-warning {{default initialization of an 
object of type 'const int' is incompatible with C++}} \
                          cxx-error {{default initialization of an object of 
const type 'const int'}}
 }
+
+// Test the behavior of flexible array members. Those cannot be initialized
+// when a stack-allocated object of the structure type is created. We handle
+// degenerate flexible arrays similarly, but only if the array does not
+// actually specify any storage. Note that C++ does not have flexible array
+// members at all, which is why the test is disabled there.
+#ifndef __cplusplus
+struct RealFAM {
----------------
AaronBallman wrote:

I think I'm going to handle unions in a separate PR; we shouldn't be diagnosing 
even on non-FAM code because default initialization of a union is fine in C++ 
(not a compat issue) so these require a bit more thought as to how best to 
handle them. e.g.,
```
union U1 {
  int i;
  const int j;
} u1; // This is fine in C++ as well as in C; you can set u.i = 12 and then 
read u.j

union U2 {
  const int i;
} u2; // This is not fine in C++ or C; you can never initialize the union, but 
do we care given how weird this code is?
```

https://github.com/llvm/llvm-project/pull/140578
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to