summaryrefslogtreecommitdiff
path: root/gcc/targhooks.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2019-04-12 19:01:17 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2019-04-12 13:01:17 -0600
commit3fb82380dcbbc768e2a5bdb5ab4079259ee0e683 (patch)
tree65f6424af90d819b32d06be37fadd150069dafa9 /gcc/targhooks.c
parent3d8695f529a41a639c6cc2a51cbcec7c8b243bc1 (diff)
PR c/88383 - ICE calling __builtin_has_attribute on a reference
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. * doc/extend.texi (__builtin_has_attribute): Add a clarifying note. 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. * c-c++-common/pr71574.c: Adjust. * gcc.dg/pr25559.c: Adjust. * gcc.dg/attr-vector_size.c: New test. From-SVN: r270326
Diffstat (limited to 'gcc/targhooks.c')
-rw-r--r--gcc/targhooks.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 318f7e9784a..cfde248dd3d 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -1247,14 +1247,18 @@ constant_alignment_word_strings (const_tree exp, HOST_WIDE_INT align)
return align;
}
-/* Default to natural alignment for vector types. */
+/* Default to natural alignment for vector types, bounded by
+ MAX_OFILE_ALIGNMENT. */
+
HOST_WIDE_INT
default_vector_alignment (const_tree type)
{
- HOST_WIDE_INT align = tree_to_shwi (TYPE_SIZE (type));
- if (align > MAX_OFILE_ALIGNMENT)
- align = MAX_OFILE_ALIGNMENT;
- return align;
+ unsigned HOST_WIDE_INT align = MAX_OFILE_ALIGNMENT;
+ tree size = TYPE_SIZE (type);
+ if (tree_fits_uhwi_p (size))
+ align = tree_to_uhwi (size);
+
+ return align < MAX_OFILE_ALIGNMENT ? align : MAX_OFILE_ALIGNMENT;
}
/* The default implementation of