aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2018-11-29 17:48:58 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2018-11-29 10:48:58 -0700
commit673670da1e5dae2aaccbade88d540cf0200f0eb3 (patch)
tree6e9c098954bf73d9254094221f8aa7aee090062f /gcc/c/c-decl.c
parent2831adb5623797825234bf006b9f2fc8f027c36d (diff)
downloadgcc-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/c-decl.c')
-rw-r--r--gcc/c/c-decl.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index cdd10ab..b50f2bf 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -11061,12 +11061,15 @@ struct c_declspecs *
declspecs_add_alignas (location_t loc,
struct c_declspecs *specs, tree align)
{
- int align_log;
specs->alignas_p = true;
specs->locations[cdw_alignas] = loc;
if (align == error_mark_node)
return specs;
- align_log = check_user_alignment (align, false, true);
+
+ /* Only accept the alignment if it's valid and greater than
+ the current one. Zero is invalid but by C11 required to
+ be silently ignored. */
+ int align_log = check_user_alignment (align, false, /* warn_zero = */false);
if (align_log > specs->align_log)
specs->align_log = align_log;
return specs;