Hi,

I think it's rather clear that we should warn in this case too, that is, when we have:

    ToBeDeprecated();

for a deprecated ToBeDeprecated type. Note however in my patchlet the check on the TREE_CODE: if I remove it, then we also warn for the lines

    x = e;

and

    y = S::f;

of g++.dg/parse/attr3.C. This seems wrong per our documentation, because those lines do not *name* the deprecated types E and F, but may make sense, for example clang++ *does* warn on those.

Tested x86_64-linux.

Thanks!
Paolo.

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

        PR c++/58305
        * semantics.c (finish_expr_stmt): 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/semantics.c
===================================================================
--- cp/semantics.c      (revision 202217)
+++ cp/semantics.c      (working copy)
@@ -620,6 +620,9 @@ finish_expr_stmt (tree expr)
        {
          if (warn_sequence_point)
            verify_sequence_points (expr);
+         if (TREE_CODE (expr) == TARGET_EXPR
+             && TREE_DEPRECATED (TREE_TYPE (expr)))
+           warn_deprecated_use (TREE_TYPE (expr), NULL_TREE);
          expr = convert_to_void (expr, ICV_STATEMENT, tf_warning_or_error);
        }
       else if (!type_dependent_expression_p (expr))
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,10 @@
+// PR c++/58305
+
+class ToBeDeprecated {
+} __attribute__ ((deprecated ("deprecated!")));
+
+int main() {
+    ToBeDeprecated();  // { dg-warning "'ToBeDeprecated' is deprecated" }
+    ToBeDeprecated x;  // { dg-warning "'ToBeDeprecated' is deprecated" }
+    return 0;
+}

Reply via email to