From 999a1ad4ec7212dc6ac0217750bcbbf86518c7db Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Fri, 9 Jul 2004 18:49:04 +0000 Subject: [PATCH] typeck.c (build_class_member_access_expr): Skip null deref warning when we don't dereference it. * typeck.c (build_class_member_access_expr): Skip null deref warning when we don't dereference it. Radar 3718909 From-SVN: r84389 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck.c | 3 ++- gcc/testsuite/g++.old-deja/g++.mike/sizeof.C | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.mike/sizeof.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3d194a43668..01112d52c3c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2004-07-09 Mike Stump + + * typeck.c (build_class_member_access_expr): Skip null deref + warning when we don't dereference it. + 2004-07-09 Giovanni Bajo PR c++/8211 diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 55b3ef3bc57..6b113255bda 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1707,7 +1707,8 @@ build_class_member_access_expr (tree object, tree member, actually used the offsetof macro, since there's no way to know at this point. So we just give a warning, instead of a pedwarn. */ if (null_object_p && warn_invalid_offsetof - && CLASSTYPE_NON_POD_P (object_type)) + && CLASSTYPE_NON_POD_P (object_type) + && ! skip_evaluation) { warning ("invalid access to non-static data member `%D' of NULL object", member); diff --git a/gcc/testsuite/g++.old-deja/g++.mike/sizeof.C b/gcc/testsuite/g++.old-deja/g++.mike/sizeof.C new file mode 100644 index 00000000000..c336a7a4642 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.mike/sizeof.C @@ -0,0 +1,9 @@ +// { dg-do compile } + +class Foo { + int children[4]; +public: + unsigned function(void) { + return sizeof (((Foo*)0)->children); + } +}; -- 2.30.2