summaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2018-03-01 19:15:42 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2018-03-01 19:15:42 +0000
commit90abdde05bf124418f83e061677f5330e15664d9 (patch)
treeaed8d219134c3c1c3be02bca744ad9396920e841 /gcc/c-family
parent4c9ce243e9f594fd22a9081ba72f50e0d1cdd508 (diff)
downloadgcc-90abdde05bf124418f83e061677f5330e15664d9.tar.gz
re PR c++/84639 (gcc/c-family/c-attribs.c:1822:27: runtime error: shift exponent -1 is negative)
PR c++/84639 * c-attribs.c (common_handle_aligned_attribute): Don't use invalid alignment in computation. From-SVN: r258109
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog6
-rw-r--r--gcc/c-family/c-attribs.c11
2 files changed, 13 insertions, 4 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 950591c053e..c10b7bff31d 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2018-03-01 Marek Polacek <polacek@redhat.com>
+
+ PR c++/84639
+ * c-attribs.c (common_handle_aligned_attribute): Don't use invalid
+ alignment in computation.
+
2018-02-28 Eric Botcazou <ebotcazou@adacore.com>
* c-ada-spec.c (dump_ada_node) <NULLPTR_TYPE>: New case.
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 0261a45ec98..3ebb2d6000c 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -1817,6 +1817,12 @@ common_handle_aligned_attribute (tree *node, tree name, tree args, int flags,
/* Log2 of specified alignment. */
int pow2align = check_user_alignment (align_expr, true);
+ if (pow2align == -1
+ || !check_cxx_fundamental_alignment_constraints (*node, pow2align, flags))
+ {
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
/* The alignment in bits corresponding to the specified alignment. */
unsigned bitalign = (1U << pow2align) * BITS_PER_UNIT;
@@ -1826,10 +1832,7 @@ common_handle_aligned_attribute (tree *node, tree name, tree args, int flags,
unsigned curalign = 0;
unsigned lastalign = 0;
- if (pow2align == -1
- || !check_cxx_fundamental_alignment_constraints (*node, pow2align, flags))
- *no_add_attrs = true;
- else if (is_type)
+ if (is_type)
{
if ((flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
/* OK, modify the type in place. */;