Comments
Patch
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" } */
this: typedef int INT1 __attribute__((deprecated("No INT1"))); INT1 f1 (void) __attribute__((deprecated("No f1"))); INT1 f2 (void) __attribute__((deprecated)); void func (void) { f1(); f2(); } should print : 'f1' is deprecated .....: No f1 'f2' is deprecated ..... but with trunk the second message is incorrectly: 'f2' is deprecated ..... : No INT1. ---- the following has been bootstrapped & regtested on i686-apple-darwin9 and checked to give the correct answer with: xgcc, g++, xgcc -x objective-c and xgcc -x objective-c++ (g++/ObjC++ modulo the issues of duplicated warnings, which is a + /* { dg-warning "'f2' is deprecated .declared at \[^\\)\]*." "f2" { target *-*-* } 11 } */ +}