c++: Avoid unnecessary deprecated warnings.
There's no need to warn that a deprecated function uses a deprecated type, that just adds noise. We were preventing that in start_decl, but that didn't help member declarations that go through grokfield. So handle it in grokdeclarator instead, which is shared between them. gcc/cp/ChangeLog 2020-05-11 Jason Merrill <jason@redhat.com> * decl.c (grokdeclarator): Adjust deprecated_state here. (start_decl): Not here.
This commit is contained in:
parent
2b2d298ff8
commit
3a3e1ea9c6
|
@ -1,3 +1,8 @@
|
|||
2020-05-11 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* decl.c (grokdeclarator): Adjust deprecated_state here.
|
||||
(start_decl): Not here.
|
||||
|
||||
2020-05-08 Iain Sandoe <iain@sandoe.co.uk>
|
||||
|
||||
PR c++/95003
|
||||
|
|
|
@ -5214,18 +5214,11 @@ start_decl (const cp_declarator *declarator,
|
|||
|
||||
*pushed_scope_p = NULL_TREE;
|
||||
|
||||
/* An object declared as __attribute__((deprecated)) suppresses
|
||||
warnings of uses of other deprecated items. */
|
||||
if (lookup_attribute ("deprecated", attributes))
|
||||
deprecated_state = DEPRECATED_SUPPRESS;
|
||||
|
||||
attributes = chainon (attributes, prefix_attributes);
|
||||
|
||||
decl = grokdeclarator (declarator, declspecs, NORMAL, initialized,
|
||||
&attributes);
|
||||
|
||||
deprecated_state = DEPRECATED_NORMAL;
|
||||
|
||||
if (decl == NULL_TREE || VOID_TYPE_P (decl)
|
||||
|| decl == error_mark_node)
|
||||
return error_mark_node;
|
||||
|
@ -11318,6 +11311,17 @@ grokdeclarator (const cp_declarator *declarator,
|
|||
type = NULL_TREE;
|
||||
type_was_error_mark_node = true;
|
||||
}
|
||||
|
||||
/* Ignore erroneous attributes. */
|
||||
if (attrlist && *attrlist == error_mark_node)
|
||||
*attrlist = NULL_TREE;
|
||||
|
||||
/* An object declared as __attribute__((deprecated)) suppresses
|
||||
warnings of uses of other deprecated items. */
|
||||
temp_override<deprecated_states> ds (deprecated_state);
|
||||
if (attrlist && lookup_attribute ("deprecated", *attrlist))
|
||||
deprecated_state = DEPRECATED_SUPPRESS;
|
||||
|
||||
cp_warn_deprecated_use (type);
|
||||
if (type && TREE_CODE (type) == TYPE_DECL)
|
||||
{
|
||||
|
|
|
@ -89,7 +89,7 @@ struct SS2 *p2; /* { dg-warning "'SS2' is deprecated: Please avoid SS2" } */
|
|||
class T {
|
||||
public:
|
||||
void member1(int) __attribute__ ((deprecated("Please avoid member1")));
|
||||
void member2(INT1) __attribute__ ((__deprecated__("Please avoid member2"))); /* { dg-warning "'INT1' is deprecated" } */
|
||||
void member2(INT1) __attribute__ ((__deprecated__("Please avoid member2")));
|
||||
int member3(T *);
|
||||
int x;
|
||||
} __attribute__ ((deprecated("Please avoid T")));
|
||||
|
|
|
@ -93,7 +93,7 @@ struct SS2 *p2; /* { dg-warning "'SS2' is deprecated" } */
|
|||
class T {
|
||||
public:
|
||||
void member1(int) __attribute__ ((deprecated));
|
||||
void member2(INT1) __attribute__ ((__deprecated__)); /* { dg-warning "'INT1' is deprecated" } */
|
||||
void member2(INT1) __attribute__ ((__deprecated__));
|
||||
int member3(T *);
|
||||
int x;
|
||||
} __attribute__ ((deprecated));
|
||||
|
|
Loading…
Reference in New Issue