diff options
author | Martin Sebor <msebor@redhat.com> | 2018-11-29 17:48:58 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2018-11-29 10:48:58 -0700 |
commit | 673670da1e5dae2aaccbade88d540cf0200f0eb3 (patch) | |
tree | 6e9c098954bf73d9254094221f8aa7aee090062f /gcc/c-family/c-common.c | |
parent | 2831adb5623797825234bf006b9f2fc8f027c36d (diff) | |
download | gcc-673670da1e5dae2aaccbade88d540cf0200f0eb3.zip gcc-673670da1e5dae2aaccbade88d540cf0200f0eb3.tar.gz gcc-673670da1e5dae2aaccbade88d540cf0200f0eb3.tar.bz2 |
PR c/88172 - attribute aligned of zero silently accepted but ignored
PR c/88172 - attribute aligned of zero silently accepted but ignored
PR testsuite/88208 - new test case c-c++-common/builtin-has-attribute-3.c in r266335 has multiple excess errors
gcc/ChangeLog:
PR c/88172
PR testsuite/88208
* doc/extend.texi (attribute constructor): Clarify.
gcc/c/ChangeLog:
PR c/88172
PR testsuite/88208
* c-decl.c (declspec_add_alignas): Adjust call to check_user_alignment.
gcc/c-family/ChangeLog:
PR c/88172
PR testsuite/88208
* c-attribs.c (common_handle_aligned_attribute): Silently avoid setting
alignments to values less than the target requires.
(has_attribute): For attribute aligned consider both the attribute
and the alignment bits.
* c-common.c (c_init_attributes): Optionally issue a warning for
zero alignment.
gcc/testsuite/ChangeLog:
PR c/88172
PR testsuite/88208
* gcc.dg/attr-aligned-2.c: New test.
* gcc.dg/builtin-has-attribute.c: Adjust.
* c-c++-common/builtin-has-attribute-2.c: Same.
* c-c++-common/builtin-has-attribute-3.c: Same.
* c-c++-common/builtin-has-attribute-4.c: Same.
* c-c++-common/builtin-has-attribute-5.c: New test.
* gcc.target/aarch64/attr-aligned.c: Same.
* gcc.target/i386/attr-aligned.c: Same.
* gcc.target/powerpc/attr-aligned.c: Same.
* gcc.target/sparc/attr-aligned.c: Same.
From-SVN: r266633
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r-- | gcc/c-family/c-common.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 9d51815..4c90365 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -5143,11 +5143,11 @@ c_init_attributes (void) then reject alignments greater than MAX_OFILE_ALIGNMENT when converted to bits. Otherwise, consider valid only alignments that are less than HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT. - If ALLOW_ZERO then 0 is valid and should result in - a return of -1 with no error. */ + Zero is not considered a valid argument (and results in -1 on + return) but it only triggers a warning when WARN_ZERO is set. */ int -check_user_alignment (const_tree align, bool objfile, bool allow_zero) +check_user_alignment (const_tree align, bool objfile, bool warn_zero) { if (error_operand_p (align)) return -1; @@ -5159,8 +5159,14 @@ check_user_alignment (const_tree align, bool objfile, bool allow_zero) return -1; } - if (allow_zero && integer_zerop (align)) - return -1; + if (integer_zerop (align)) + { + if (warn_zero) + warning (OPT_Wattributes, + "requested alignment %qE is not a positive power of 2", + align); + return -1; + } int log2bitalign; if (tree_int_cst_sgn (align) == -1 |