diff mbox

[C++] PR 58305

Message ID 5225FBDC.7010805@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Sept. 3, 2013, 3:10 p.m. UTC
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.carlini@oracle.com>

	PR c++/58305
	* semantics.c (finish_expr_stmt): Maybe warn_deprecated_use.

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

	PR c++/58305
	* g++.dg/warn/deprecated-8.C: New.

Comments

Paolo Carlini Sept. 3, 2013, 6:04 p.m. UTC | #1
.. unfortunately the issue isn't so easy because in any case we don't 
want to warn for typedefs of ToBeDeprecated.

Paolo.
Jason Merrill Sept. 3, 2013, 9:32 p.m. UTC | #2
On 09/03/2013 11:10 AM, Paolo Carlini wrote:
>     ToBeDeprecated();

I'd rather handle this case in build_functional_cast.

Jason
diff mbox

Patch

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;
+}