Avoid duplicate visibility warning.
authorJason Merrill <jason@redhat.com>
Mon, 20 Nov 2017 22:37:45 +0000 (17:37 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 20 Nov 2017 22:37:45 +0000 (17:37 -0500)
* decl2.c (constrain_class_visibility): Don't warn about artificial
fields.

From-SVN: r254973

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/g++.dg/ext/visibility/warn6.C [new file with mode: 0644]

index 31b20ffa3e0f52c2237b3d2103a023262193674a..5de732f5425d4d6f50c1072cc49a7569c0495c71 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-20  Jason Merrill  <jason@redhat.com>
+
+       * decl2.c (constrain_class_visibility): Don't warn about artificial
+       fields.
+
 2017-11-20  Jakub Jelinek  <jakub@redhat.com>
 
        P0329R4: Designated Initialization
index bc0db0000deb049186441aaa0d73d26a52f1849f..13e7b1d180a8932c4b5e122ee0df6a79249877ab 100644 (file)
@@ -2553,7 +2553,8 @@ constrain_class_visibility (tree type)
     vis = VISIBILITY_INTERNAL;
 
   for (t = TYPE_FIELDS (type); t; t = DECL_CHAIN (t))
-    if (TREE_CODE (t) == FIELD_DECL && TREE_TYPE (t) != error_mark_node)
+    if (TREE_CODE (t) == FIELD_DECL && TREE_TYPE (t) != error_mark_node
+       && !DECL_ARTIFICIAL (t))
       {
        tree ftype = strip_pointer_or_array_types (TREE_TYPE (t));
        int subvis = type_visibility (ftype);
diff --git a/gcc/testsuite/g++.dg/ext/visibility/warn6.C b/gcc/testsuite/g++.dg/ext/visibility/warn6.C
new file mode 100644 (file)
index 0000000..256ebd2
--- /dev/null
@@ -0,0 +1,2 @@
+struct __attribute ((visibility ("hidden"))) A { int i; };
+struct B: A { }; // { dg-warning "base" }