diff options
author | Jason Merrill <jason@redhat.com> | 2012-03-01 12:52:12 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2012-03-01 12:52:12 -0500 |
commit | ae45549b504fce6b72561105cbf0cef4b952884a (patch) | |
tree | 9cf09f96fe4467f1771a7728f6681c1e6269bbcb | |
parent | 116b061e74bb406778c8ec140310588794d8c1ef (diff) | |
download | gcc-ae45549b504fce6b72561105cbf0cef4b952884a.zip gcc-ae45549b504fce6b72561105cbf0cef4b952884a.tar.gz gcc-ae45549b504fce6b72561105cbf0cef4b952884a.tar.bz2 |
re PR c++/51930 (Explicitly instantiated template gets hidden visibility)
PR c++/51930
* decl.c (check_tag_decl): Move warning for misplaced attributes here.
(shadow_tag): From here.
* parser.c (cp_parser_explicit_instantiation): Don't warn here.
From-SVN: r184753
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 21 | ||||
-rw-r--r-- | gcc/cp/parser.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/attrib43.C | 2 |
4 files changed, 21 insertions, 12 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2c81a8a..6a92eeb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2012-02-29 Jason Merrill <jason@redhat.com> + + PR c++/51930 + * decl.c (check_tag_decl): Move warning for misplaced attributes here. + (shadow_tag): From here. + * parser.c (cp_parser_explicit_instantiation): Don't warn here. + 2012-02-21 Jakub Jelinek <jakub@redhat.com> PR c++/52312 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2a6a516..c47f87c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4216,6 +4216,19 @@ check_tag_decl (cp_decl_specifier_seq *declspecs) error ("%<constexpr%> cannot be used for type declarations"); } + if (declspecs->attributes) + { + location_t loc = input_location; + if (!CLASSTYPE_TEMPLATE_INSTANTIATION (declared_type)) + /* For a non-template class, use the name location; for a template + class (an explicit instantiation), use the current location. */ + input_location = location_of (declared_type); + warning (0, "attribute ignored in declaration of %q#T", declared_type); + warning (0, "attribute for %q#T must follow the %qs keyword", + declared_type, class_key_or_enum_as_string (declared_type)); + input_location = loc; + } + return declared_type; } @@ -4240,14 +4253,6 @@ shadow_tag (cp_decl_specifier_seq *declspecs) if (!t) return NULL_TREE; - if (declspecs->attributes) - { - warning (0, "attribute ignored in declaration of %q+#T", t); - warning (0, "attribute for %q+#T must follow the %qs keyword", - t, class_key_or_enum_as_string (t)); - - } - if (maybe_process_partial_specialization (t) == error_mark_node) return NULL_TREE; diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3e2be97..491f48e 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13122,9 +13122,6 @@ cp_parser_explicit_instantiation (cp_parser* parser) tree type; type = check_tag_decl (&decl_specifiers); - if (decl_specifiers.attributes) - warning (OPT_Wattributes, - "attributes ignored on explicit type instantiation"); /* Turn access control back on for names used during template instantiation. */ pop_deferring_access_checks (); diff --git a/gcc/testsuite/g++.dg/ext/attrib43.C b/gcc/testsuite/g++.dg/ext/attrib43.C index fe9f072..acae3f2 100644 --- a/gcc/testsuite/g++.dg/ext/attrib43.C +++ b/gcc/testsuite/g++.dg/ext/attrib43.C @@ -2,4 +2,4 @@ template <class T> struct A { }; template __attribute__ ((packed)) -struct A<int>; // { dg-warning "attributes ignored" } +struct A<int>; // { dg-warning "attribute" } |