]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2018-07-12 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jul 2018 07:13:36 +0000 (07:13 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 12 Jul 2018 07:13:36 +0000 (07:13 +0000)
PR c/86453
* c-attribs.c (handle_packed_attribute): Do not build a variant
type with TYPE_PACKED, instead ignore the attribute if we may
not apply to the original type.

* g++.dg/warn/pr86453.C: New testcase.

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

gcc/c-family/ChangeLog
gcc/c-family/c-attribs.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pr86453.C [new file with mode: 0644]

index a459f0613265c20435a3b9fa5a907b16d27d51d1..115e032e41d7cba2c8076130029858f7943d0d8a 100644 (file)
@@ -1,3 +1,10 @@
+2018-07-12  Richard Biener  <rguenther@suse.de>
+
+       PR c/86453
+       * c-attribs.c (handle_packed_attribute): Do not build a variant
+       type with TYPE_PACKED, instead ignore the attribute if we may
+       not apply to the original type.
+
 2018-07-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/86443
index f91add488bbb5d39365beec2f6b6c37d803c9e4c..8cb87eb81543faee3ec1f8409f38656c48a4373d 100644 (file)
@@ -502,8 +502,13 @@ handle_packed_attribute (tree *node, tree name, tree ARG_UNUSED (args),
   if (TYPE_P (*node))
     {
       if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
-       *node = build_variant_type_copy (*node);
-      TYPE_PACKED (*node) = 1;
+       {
+         warning (OPT_Wattributes,
+                  "%qE attribute ignored for type %qT", name, *node);
+         *no_add_attrs = true;
+       }
+      else
+       TYPE_PACKED (*node) = 1;
     }
   else if (TREE_CODE (*node) == FIELD_DECL)
     {
index 0958a1a57b21cbdf63788bfe9278344da50805db..d68cccf3d0b2a6a35a1144a7c31a94d6e5058163 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-12  Richard Biener  <rguenther@suse.de>
+
+       PR c/86453
+       * g++.dg/warn/pr86453.C: New testcase.
+
 2018-07-12  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/86479
diff --git a/gcc/testsuite/g++.dg/warn/pr86453.C b/gcc/testsuite/g++.dg/warn/pr86453.C
new file mode 100644 (file)
index 0000000..318f406
--- /dev/null
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-additional-options "-flto" { target lto } }
+struct X {
+  int *__attribute__((aligned(2), packed)) a; // { dg-warning "attribute ignored" }
+} b;