From 753c2e693fd35b582b34e66ac877cd1a4a385be7 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 20 Nov 2017 17:37:45 -0500 Subject: [PATCH] Avoid duplicate visibility warning. * decl2.c (constrain_class_visibility): Don't warn about artificial fields. From-SVN: r254973 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl2.c | 3 ++- gcc/testsuite/g++.dg/ext/visibility/warn6.C | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/visibility/warn6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 31b20ffa3e0..5de732f5425 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-11-20 Jason Merrill + + * decl2.c (constrain_class_visibility): Don't warn about artificial + fields. + 2017-11-20 Jakub Jelinek P0329R4: Designated Initialization diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index bc0db0000de..13e7b1d180a 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -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 index 00000000000..256ebd2ad2f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/visibility/warn6.C @@ -0,0 +1,2 @@ +struct __attribute ((visibility ("hidden"))) A { int i; }; +struct B: A { }; // { dg-warning "base" } -- 2.30.2