On 09/03/2013 11:32 PM, Jason Merrill wrote:
On 09/03/2013 11:10 AM, Paolo Carlini wrote:
    ToBeDeprecated();

I'd rather handle this case in build_functional_cast.
Indeed. Thanks for the great tip. A tried to find a place where I could use the same check we have in grokdeclarator, involving DECL_ARTIFICIAL on a TYPE_DECL, but failed, shame on me.

Anyway, I'm finishing testing the below on x86_64-linux.

Thanks,
Paolo.

///////////////////////


/cp
2013-09-03  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58305
        * typeck2.c (build_functional_cast): Maybe warn_deprecated_use.

/testsuite
2013-09-03  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/58305
        * g++.dg/warn/deprecated-8.C: New.
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c        (revision 202231)
+++ cp/typeck2.c        (working copy)
@@ -1761,7 +1761,14 @@ build_functional_cast (tree exp, tree parms, tsubs
     return error_mark_node;
 
   if (TREE_CODE (exp) == TYPE_DECL)
-    type = TREE_TYPE (exp);
+    {
+      type = TREE_TYPE (exp);
+
+      if (complain & tf_warning
+         && TREE_DEPRECATED (type)
+         && DECL_ARTIFICIAL (exp))
+       warn_deprecated_use (type, NULL_TREE);
+    }
   else
     type = exp;
 
Index: testsuite/g++.dg/warn/deprecated-8.C
===================================================================
--- testsuite/g++.dg/warn/deprecated-8.C        (revision 0)
+++ testsuite/g++.dg/warn/deprecated-8.C        (working copy)
@@ -0,0 +1,15 @@
+// PR c++/58305
+
+class ToBeDeprecated {
+} __attribute__ ((deprecated ("deprecated!")));
+
+typedef ToBeDeprecated NotToBeDeprecated; // { dg-warning "'ToBeDeprecated' is 
deprecated" }
+
+int main() {
+
+  ToBeDeprecated();    // { dg-warning "'ToBeDeprecated' is deprecated" }
+  ToBeDeprecated x;    // { dg-warning "'ToBeDeprecated' is deprecated" }
+
+  NotToBeDeprecated();
+  NotToBeDeprecated y;
+}

Reply via email to