Commit 98cf9ac9 by Paolo Carlini Committed by Paolo Carlini

re PR c++/56130 (__attribute__((deprecated)) does not affect C++ reference)

2013-08-21  Paolo Carlini  <paolo.carlini@oracle.com>

	* call.c (build_new_method_call_1): Use INDIRECT_REF_P.
	* cp-tree.h (REFERENCE_REF_P): Likewise.
	* semantics.c (finish_offsetof): Likewise.


/cp
2013-08-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56130
	* semantics.c (finish_id_expression): Handle deprecated references.

/testsuite
2013-08-21  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/56130
	* g++.dg/warn/deprecated-7.C: New.

From-SVN: r201906
parent dd5e8423
2013-08-21 Paolo Carlini <paolo.carlini@oracle.com>
* call.c (build_new_method_call_1): Use INDIRECT_REF_P.
* cp-tree.h (REFERENCE_REF_P): Likewise.
* semantics.c (finish_offsetof): Likewise.
2013-08-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56130
* semantics.c (finish_id_expression): Handle deprecated references.
2013-08-20 Jason Merrill <jason@redhat.com> 2013-08-20 Jason Merrill <jason@redhat.com>
PR c++/58119 PR c++/58119
......
...@@ -7668,7 +7668,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, ...@@ -7668,7 +7668,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args,
if (init) if (init)
{ {
if (TREE_CODE (instance) == INDIRECT_REF if (INDIRECT_REF_P (instance)
&& integer_zerop (TREE_OPERAND (instance, 0))) && integer_zerop (TREE_OPERAND (instance, 0)))
return get_target_expr_sfinae (init, complain); return get_target_expr_sfinae (init, complain);
init = build2 (INIT_EXPR, TREE_TYPE (instance), instance, init); init = build2 (INIT_EXPR, TREE_TYPE (instance), instance, init);
......
...@@ -2975,7 +2975,7 @@ extern void decl_shadowed_for_var_insert (tree, tree); ...@@ -2975,7 +2975,7 @@ extern void decl_shadowed_for_var_insert (tree, tree);
/* True if NODE is an implicit INDIRECT_EXPR from convert_from_reference. */ /* True if NODE is an implicit INDIRECT_EXPR from convert_from_reference. */
#define REFERENCE_REF_P(NODE) \ #define REFERENCE_REF_P(NODE) \
(TREE_CODE (NODE) == INDIRECT_REF \ (INDIRECT_REF_P (NODE) \
&& TREE_TYPE (TREE_OPERAND (NODE, 0)) \ && TREE_TYPE (TREE_OPERAND (NODE, 0)) \
&& (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \ && (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \
== REFERENCE_TYPE)) == REFERENCE_TYPE))
......
...@@ -3457,8 +3457,10 @@ finish_id_expression (tree id_expression, ...@@ -3457,8 +3457,10 @@ finish_id_expression (tree id_expression,
} }
} }
if (TREE_DEPRECATED (decl)) /* Handle references (c++/56130). */
warn_deprecated_use (decl, NULL_TREE); tree t = REFERENCE_REF_P (decl) ? TREE_OPERAND (decl, 0) : decl;
if (TREE_DEPRECATED (t))
warn_deprecated_use (t, NULL_TREE);
return decl; return decl;
} }
...@@ -3691,7 +3693,7 @@ finish_offsetof (tree expr) ...@@ -3691,7 +3693,7 @@ finish_offsetof (tree expr)
|| TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
|| TREE_TYPE (expr) == unknown_type_node) || TREE_TYPE (expr) == unknown_type_node)
{ {
if (TREE_CODE (expr) == INDIRECT_REF) if (INDIRECT_REF_P (expr))
error ("second operand of %<offsetof%> is neither a single " error ("second operand of %<offsetof%> is neither a single "
"identifier nor a sequence of member accesses and " "identifier nor a sequence of member accesses and "
"array references"); "array references");
......
2013-08-21 Paolo Carlini <paolo.carlini@oracle.com> 2013-08-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/56130
* g++.dg/warn/deprecated-7.C: New.
2013-08-21 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/tree-prof/pr57451.C: Remove spurious dg-do directive. * g++.dg/tree-prof/pr57451.C: Remove spurious dg-do directive.
2013-08-21 Jeff Law <law@redhat.com> 2013-08-21 Jeff Law <law@redhat.com>
......
// PR c++/56130
int g_nn;
int& g_n __attribute__((deprecated)) = g_nn;
void f()
{
int f_nn;
int& f_n __attribute__((deprecated)) = f_nn;
f_n = 1; // { dg-warning "'f_n' is deprecated" }
}
int main()
{
g_n = 1; // { dg-warning "'g_n' is deprecated" }
f();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment