<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 24, 2014 at 3:27 PM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">> -----Original Message-----<br>
> From: <a href="mailto:cfe-commits-bounces@cs.uiuc.edu">cfe-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-commits-">cfe-commits-</a><br>
> <a href="mailto:bounces@cs.uiuc.edu">bounces@cs.uiuc.edu</a>] On Behalf Of David Majnemer<br>
> Sent: Wednesday, September 24, 2014 4:04 AM<br>
> To: <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> Subject: r218378 - Sema: Inherit the flexible array property from struct<br>
> fields<br>
><br>
> Author: majnemer<br>
> Date: Wed Sep 24 06:04:09 2014<br>
> New Revision: 218378<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=218378&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=218378&view=rev</a><br>
> Log:<br>
> Sema: Inherit the flexible array property from struct fields<br>
><br>
> A record which contains a flexible array member is itself a flexible<br>
> array member.  A struct which contains such a record should also<br>
> consider itself to be a flexible array member.<br>
><br>
> Modified:<br>
>     cfe/trunk/lib/Sema/SemaDecl.cpp<br>
>     cfe/trunk/test/SemaCXX/flexible-array-test.cpp<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=218378&r1=218377&r2=218378&vie<br>
> w=diff<br>
> ==========================================================================<br>
> ====<br>
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 24 06:04:09 2014<br>
> @@ -12704,8 +12704,7 @@ void Sema::ActOnFields(Scope *S, SourceL<br>
>          continue;<br>
>        }<br>
>        // Okay, we have a legal flexible array member at the end of the<br>
> struct.<br>
> -      if (Record)<br>
> -        Record->setHasFlexibleArrayMember(true);<br>
> +      Record->setHasFlexibleArrayMember(true);<br>
>      } else if (!FDTy->isDependentType() &&<br>
>                 RequireCompleteType(FD->getLocation(), FD->getType(),<br>
>                                     diag::err_field_incomplete)) {<br>
> @@ -12714,11 +12713,11 @@ void Sema::ActOnFields(Scope *S, SourceL<br>
>        EnclosingDecl->setInvalidDecl();<br>
>        continue;<br>
>      } else if (const RecordType *FDTTy = FDTy->getAs<RecordType>()) {<br>
> -      if (FDTTy->getDecl()->hasFlexibleArrayMember()) {<br>
> -        // If this is a member of a union, then entire union becomes<br>
> "flexible".<br>
> -        if (Record && Record->isUnion()) {<br>
> -          Record->setHasFlexibleArrayMember(true);<br>
> -        } else {<br>
> +      if (Record && FDTTy->getDecl()->hasFlexibleArrayMember()) {<br>
> +        // A type which contains a flexible array member is considered to<br>
> be a<br>
> +        // flexible array member.<br>
> +        Record->setHasFlexibleArrayMember(true);<br>
> +        if (!Record->isUnion()) {<br>
>            // If this is a struct/class and this is not the last element,<br>
> reject<br>
>            // it.  Note that GCC supports variable sized arrays in the<br>
> middle of<br>
>            // structures.<br>
> @@ -12730,8 +12729,6 @@ void Sema::ActOnFields(Scope *S, SourceL<br>
>              // other structs as an extension.<br>
>              Diag(FD->getLocation(), diag::ext_flexible_array_in_struct)<br>
>                << FD->getDeclName();<br>
> -            if (Record)<br>
> -              Record->setHasFlexibleArrayMember(true);<br>
>            }<br>
>          }<br>
>        }<br>
><br>
> Modified: cfe/trunk/test/SemaCXX/flexible-array-test.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/flexible-" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/flexible-</a><br>
> array-test.cpp?rev=218378&r1=218377&r2=218378&view=diff<br>
> ==========================================================================<br>
> ====<br>
> --- cfe/trunk/test/SemaCXX/flexible-array-test.cpp (original)<br>
> +++ cfe/trunk/test/SemaCXX/flexible-array-test.cpp Wed Sep 24 06:04:09<br>
> 2014<br>
> @@ -14,6 +14,12 @@ void QMap<Key, T>::insert(const Key &, c<br>
>    v = avalue;<br>
>  }<br>
><br>
> +struct Rec {<br>
> +  union { // expected-warning-re {{variable sized type '{{.*}}' not at<br>
> the end of a struct or class is a GNU extension}}<br>
> +    int u0[];<br>
> +  };<br>
> +  int x;<br>
> +} rec;<br>
<br>
</div></div>If this is for PR21040, maybe there should be another test for array[0]?<br>
(Also would be nice to mention the PR in the commit log...)<br>
But if this isn't the complete fix for 21040... "never mind."<br></blockquote><div><br></div><div>This fixes a different bug, we were crashing elsewhere in Sema when checking the implicit constructor because we saw an incomplete array type in an unexpected case.</div><div><br></div><div>PR21040 is a different matter, we need to consider a constant array with a bound of zero to be a flexible array member.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Thanks,<br>
--paulr<br>
<div class=""><div class="h5"><br>
><br>
>  struct inotify_event<br>
>  {<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>