ahatanak added inline comments.
================
Comment at: include/clang/AST/Decl.h:3250
+ /// This is true if this struct ends with an array marked 'flexible_array'.
+ bool HasFlexibleArrayAttr : 1;
+
----------------
ahatanak wrote:
> rsmith wrote:
> > How is this different from `HasFlexibleArrayMember`? Do we really need both?
> As I commented below, we don't need both if we are going to treat an array
> with flexible_array attribute like other existing flexible arrays.
I forgot to mention this, but one reason I didn't treat arrays with
flexible_array attribute as C99 flexible arrays is that there are a couple of
places in IRGen (TargetInfo.cpp) that call hasFlexibleArrayMember() to decide
how to pass arguments to functions. For example, when I compile the following
code with "-arch arm64", the first function receives a pointer while the second
one receives a value:
```
typedef struct {
int a;
int b[5];
} S0;
typedef struct {
int a;
int b[];
} S1;
S0 g0;
S1 g1;
void foo0(S0 s0) {
g0 = s0;
}
void foo1(S1 s1) {
g1 = s1;
}
```
I agree with you that treating flexible_arrays as C99 flexible arrays will
probably keep the code simple and clean, but I have to see if anyone is using
structs with flexible arrays in way that will cause ABI breakage.
https://reviews.llvm.org/D21453
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits