]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/84639
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Mar 2018 19:15:42 +0000 (19:15 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 1 Mar 2018 19:15:42 +0000 (19:15 +0000)
* c-attribs.c (common_handle_aligned_attribute): Don't use invalid
alignment in computation.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258109 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/c-family/ChangeLog
gcc/c-family/c-attribs.c

index 950591c053e83c5b69b5dbb92c5df06553cee7c5..c10b7bff31db810df486ec08f6d9efb09a47307d 100644 (file)
@@ -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.
index 0261a45ec980739e482af2dcc27f2be51070d778..3ebb2d6000cc481cbc226e780dcfc7b3bc20d80b 100644 (file)
@@ -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.  */;