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
This commit is contained in:
Mike Stump 2004-07-09 18:49:04 +00:00 committed by Mike Stump
parent 85fd2947bd
commit 999a1ad4ec
3 changed files with 16 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2004-07-09 Mike Stump <mrs@apple.com>
* typeck.c (build_class_member_access_expr): Skip null deref
warning when we don't dereference it.
2004-07-09 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/8211

View File

@ -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);

View File

@ -0,0 +1,9 @@
// { dg-do compile }
class Foo {
int children[4];
public:
unsigned function(void) {
return sizeof (((Foo*)0)->children);
}
};