diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2013-08-21 19:06:05 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2013-08-21 19:06:05 +0000 |
commit | 98cf9ac919f9901c024e6a8e14096610beb7f7ea (patch) | |
tree | eac762d9b0be22125e42d8ef0a46b61668e001f7 /gcc | |
parent | dd5e84232f4b63d3fb56ad9be5d0fe016b075856 (diff) | |
download | gcc-98cf9ac919f9901c024e6a8e14096610beb7f7ea.zip gcc-98cf9ac919f9901c024e6a8e14096610beb7f7ea.tar.gz gcc-98cf9ac919f9901c024e6a8e14096610beb7f7ea.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/call.c | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 2 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/warn/deprecated-7.C | 17 |
6 files changed, 40 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c18bcb5..c99f948 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +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> PR c++/58119 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index df87d8f..f8fab08 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7668,7 +7668,7 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, if (init) { - if (TREE_CODE (instance) == INDIRECT_REF + if (INDIRECT_REF_P (instance) && integer_zerop (TREE_OPERAND (instance, 0))) return get_target_expr_sfinae (init, complain); init = build2 (INIT_EXPR, TREE_TYPE (instance), instance, init); diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 51dab8a..3c5201f 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -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. */ #define REFERENCE_REF_P(NODE) \ - (TREE_CODE (NODE) == INDIRECT_REF \ + (INDIRECT_REF_P (NODE) \ && TREE_TYPE (TREE_OPERAND (NODE, 0)) \ && (TREE_CODE (TREE_TYPE (TREE_OPERAND ((NODE), 0))) \ == REFERENCE_TYPE)) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fa47db7..ee3503c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3457,8 +3457,10 @@ finish_id_expression (tree id_expression, } } - if (TREE_DEPRECATED (decl)) - warn_deprecated_use (decl, NULL_TREE); + /* Handle references (c++/56130). */ + tree t = REFERENCE_REF_P (decl) ? TREE_OPERAND (decl, 0) : decl; + if (TREE_DEPRECATED (t)) + warn_deprecated_use (t, NULL_TREE); return decl; } @@ -3691,7 +3693,7 @@ finish_offsetof (tree expr) || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE || 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 " "identifier nor a sequence of member accesses and " "array references"); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f5f3326..e117f84 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 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. 2013-08-21 Jeff Law <law@redhat.com> diff --git a/gcc/testsuite/g++.dg/warn/deprecated-7.C b/gcc/testsuite/g++.dg/warn/deprecated-7.C new file mode 100644 index 0000000..f564a1b --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/deprecated-7.C @@ -0,0 +1,17 @@ +// 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(); +} |