aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-11-23 15:35:31 -0700
committerMartin Sebor <msebor@redhat.com>2021-11-23 15:36:03 -0700
commit2dd56aed3e4e1938a9020ab2fe6a410e1a1c2eb3 (patch)
tree4371702e64925754d28d313697752ba71010170d /gcc/cp
parent30ba058f77eedfaf7a0582f5d42aff949710bce4 (diff)
downloadgcc-2dd56aed3e4e1938a9020ab2fe6a410e1a1c2eb3.zip
gcc-2dd56aed3e4e1938a9020ab2fe6a410e1a1c2eb3.tar.gz
gcc-2dd56aed3e4e1938a9020ab2fe6a410e1a1c2eb3.tar.bz2
Issue -Waddress also for reference members [PR96507].
Resolves: PR c++/96507 - missing -Waddress for member references gcc/cp/ChangeLog: PR c++/96507 * typeck.c (warn_for_null_address): Handle reference members. gcc/testsuite/ChangeLog: PR c++/96507 * g++.dg/warn/Waddress-8.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/typeck.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 84dcb6f..872e944 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4677,10 +4677,13 @@ warn_for_null_address (location_t location, tree op, tsubst_flags_t complain)
return;
}
else if (CONVERT_EXPR_P (op)
- && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (op, 0))))
+ && TYPE_REF_P (TREE_TYPE (TREE_OPERAND (op, 0))))
{
STRIP_NOPS (op);
+ if (TREE_CODE (op) == COMPONENT_REF)
+ op = TREE_OPERAND (op, 1);
+
if (DECL_P (op))
warned = warning_at (location, OPT_Waddress,
"the compiler can assume that the address of "