different PR)
I have only attached a testcase to "C" since the principal change is
in common code.
OK for trunk?
Iain
----
gcc/
PR c/43797
* toplev.c: Handle deprecated attribute search consistently.
gcc/c-family
PR c/43797
* c-common.c: Attach __attribute__(deprecated), even when there is no
deprecation
advice message.
testsuite/
PR c/43797
* gcc.dg/pr43797.c: New.
===
===================================================================
@@ -867,15 +867,16 @@ warn_deprecated_use (tree node, tree attr)
{
tree decl = TYPE_STUB_DECL (node);
if (decl)
- attr = lookup_attribute ("deprecated",
- TYPE_ATTRIBUTES (TREE_TYPE (decl)));
+ attr = TYPE_ATTRIBUTES (TREE_TYPE (decl));
+ else
+ attr = TYPE_ATTRIBUTES (node);
}
}
if (attr)
attr = lookup_attribute ("deprecated", attr);
- if (attr)
+ if (attr && TREE_VALUE (attr) && TREE_VALUE (TREE_VALUE (attr)))
msg = TREE_STRING_POINTER (TREE_VALUE (TREE_VALUE (attr)));
else
msg = NULL;
===================================================================
@@ -7115,13 +7115,8 @@ handle_deprecated_attribute (tree *node, tree
name
int warn = 0;
tree what = NULL_TREE;
- if (!args)
- *no_add_attrs = true;
- else if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
- {
- error ("deprecated message is not a string");
- *no_add_attrs = true;
- }
+ if (args && TREE_CODE (TREE_VALUE (args)) != STRING_CST)
+ error ("deprecated message is not a string");
if (DECL_P (*node))
{
===================================================================
@@ -0,0 +1,13 @@
+/* pr 43797 */
+/* dg-do compile */
+
+typedef int INT1 __attribute__((deprecated("No INT1")));
+INT1 f1 (void) __attribute__((deprecated("No f1")));
+INT1 f2 (void) __attribute__((deprecated));
+
+void func (void)
+{
+ f1(); /* { dg-warning "'f1' is deprecated .declared at \[^\\)\]*.:
No f1" "f1" } */
+ f2(); /* { dg-bogus "'f2' is deprecated .declared at \[^\\)\]*.:
No INT1" "f2-wrong deprecation message" } */