From d6221ad4589004958d05d4ac3cb7104881dfe896 Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Wed, 2 Dec 2015 19:29:17 +0000 Subject: [PATCH] re PR c++/68653 (ICE: in nonnull_arg_p, at tree.c:13853) PR c++/68653 * tree.c (nonnull_arg_p): Allow OFFSET_TYPE. * g++.dg/warn/nonnull3.C: New test. From-SVN: r231200 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/warn/nonnull3.C | 19 +++++++++++++++++++ gcc/tree.c | 4 +++- 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/warn/nonnull3.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d335b2ef475..845d9098a39 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-12-02 Marek Polacek + + PR c++/68653 + * tree.c (nonnull_arg_p): Allow OFFSET_TYPE. + 2015-12-02 Nathan Sidwell * config/nvptx/nvptx.c (enum nvptx_shuffle_kind): New. Absorb diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index feb0a0ae523..e8291a9d426 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-12-02 Marek Polacek + + PR c++/68653 + * g++.dg/warn/nonnull3.C: New test. + 2015-12-02 Joseph Myers PR c/68162 diff --git a/gcc/testsuite/g++.dg/warn/nonnull3.C b/gcc/testsuite/g++.dg/warn/nonnull3.C new file mode 100644 index 00000000000..d82fa31d957 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/nonnull3.C @@ -0,0 +1,19 @@ +// PR c++/68653 +// { dg-do compile { target c++11 } } +// { dg-options "-Wall" } + +struct B; +struct A { + template __attribute__((nonnull)) bool foo (int T::*); + void bar (B *); +}; + +template bool A::foo (int T::*p) +{ + return p; +} +void A::bar (B *) +{ + foo ((int B::*) nullptr); +} +// { dg-warning "nonnull argument" "" {target "*-*-*"} 0 } diff --git a/gcc/tree.c b/gcc/tree.c index 587bd7457df..bd5cf73b659 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -13848,7 +13848,9 @@ nonnull_arg_p (const_tree arg) tree t, attrs, fntype; unsigned HOST_WIDE_INT arg_num; - gcc_assert (TREE_CODE (arg) == PARM_DECL && POINTER_TYPE_P (TREE_TYPE (arg))); + gcc_assert (TREE_CODE (arg) == PARM_DECL + && (POINTER_TYPE_P (TREE_TYPE (arg)) + || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE)); /* The static chain decl is always non null. */ if (arg == cfun->static_chain_decl) -- 2.30.2