On 4/2/19 3:19 PM, Martin Sebor wrote:
> This is yet another follow up on the discussion of the fix for
> the ICE in __builtin_has_attribute that started last December
> with PR88383.
> 
> After my last post last week I went and added more tests to make
> sure the built-in behaves as intended by comparing its result for
> non-trivial expressions with that of __alignof__.  The test that
> does this is the new builtin-has-attribute-7.c.
> 
> The test exposed one problem in the handling of attribute vector_size
> by the built-in (I mentioned that in my last post).  It also exposed
> a couple of bugs in the attribute handler itself.  I fixed both of
> these in the attached patch.
> 
> This latest revision of the patch resolves the following bugs:
> 
>   PR 88383 - ICE calling __builtin_has_attribute on a reference
>   PR 89288 - ICE in tree_code_size, at tree.c:865
>   PR 89798 - excessive vector_size silently accepted and truncated
>   PR 89797 - ICE on a vector_size (1LU << 33) int variable
> 
> Bootstrapped on x86_64-linux.  The tests are still running but
> assuming they pass, is this last revision good to commit?
> 
> Martin
> 
> A link to my last comment in the archive:
>   https://gcc.gnu.org/ml/gcc-patches/2019-03/msg01096.html
> 
> gcc-88383.diff
> 
> PR c/88383 - ICE calling __builtin_has_attribute on a reference
> PR c/89288 - ICE in tree_code_size, at tree.c:865
> PR c/89798 - excessive vector_size silently accepted and truncated
> PR c/89797 - ICE on a vector_size (1LU << 33) int variable
> 
> gcc/ChangeLog:
> 
>       PR c/89797
>       * targhooks.c (default_vector_alignment): Avoid assuming
>       argument fits in SHWI.
>       * tree.h (TYPE_VECTOR_SUBPARTS): Avoid sign overflow in
>       a shift expression.
> 
> gcc/c-family/ChangeLog:
> 
>       PR c/88383
>       PR c/89288
>       PR c/89798
>       PR c/89797
>       * c-attribs.c (type_valid_for_vector_size): Detect excessively
>       large sizes.
>       (validate_attribute): Handle DECLs and expressions.
>       (has_attribute): Handle types referenced by expressions.
>       Avoid considering array attributes in ARRAY_REF expressions .
> 
> gcc/cp/ChangeLog:
> 
>       PR c/88383
>       PR c/89288
>       * parser.c (cp_parser_has_attribute_expression): Handle assignment
>       expressions.
> 
> gcc/testsuite/ChangeLog:
> 
>       PR c/88383
>       PR c/89288
>       PR c/89798
>       PR c/89797
>       * c-c++-common/attributes-1.c: Adjust.
>       * c-c++-common/builtin-has-attribute-6.c: New test.
>       * c-c++-common/builtin-has-attribute-7.c: New test.
>       * c-c++-common/builtin-has-attribute-4.c: Adjust expectations.
>       * c-c++-common/builtin-has-attribute-6.c: New test.
>       * gcc.dg/pr25559.c: Adjust.
>       * gcc.dg/attr-vector_size.c: New test.
Per our offline discussion, I think this is OK with some documentation
updates to clarify expression handling.

In particular can you adjust the docs to more clearly indicate that for
an expression, we look at the attributes of the type of the expression.

With a suitable doc change of that nature, this is OK.

jeff

Reply via email to