From e4f0733af41d5fa2035f6eceb24a74ccba13afcf Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 2 Aug 2017 09:28:21 +0200 Subject: [PATCH] re PR c++/81640 (ICE in lookup_fnfields_slot_nolazy w/ -Wshadow=compatible-local) PR c++/81640 * call.c (build_user_type_conversion_1): Only call lookup_fnfields_slot if totype is CLASS_TYPE_P. * g++.dg/warn/Wshadow-compatible-local-2.C: New test. From-SVN: r250816 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/call.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ .../g++.dg/warn/Wshadow-compatible-local-2.C | 21 +++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 03a9d086408..8be42940bd8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-08-02 Jakub Jelinek + + PR c++/81640 + * call.c (build_user_type_conversion_1): Only call + lookup_fnfields_slot if totype is CLASS_TYPE_P. + 2017-07-31 Jason Merrill * decl.c (declare_global_var): Set DECL_CONTEXT. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index e74d48daa8b..f633fa5ad91 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3735,7 +3735,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags, gcc_assert (!MAYBE_CLASS_TYPE_P (fromtype) || !MAYBE_CLASS_TYPE_P (totype) || !DERIVED_FROM_P (totype, fromtype)); - if (MAYBE_CLASS_TYPE_P (totype)) + if (CLASS_TYPE_P (totype)) /* Use lookup_fnfields_slot instead of lookup_fnfields to avoid creating a garbage BASELINK; constructors can't be inherited. */ ctors = lookup_fnfields_slot (totype, complete_ctor_identifier); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 41ccd0df844..142e4de0e73 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-08-02 Jakub Jelinek + PR c++/81640 + * g++.dg/warn/Wshadow-compatible-local-2.C: New test. + PR middle-end/79499 * gcc.dg/pr79499.c: New test. diff --git a/gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-2.C b/gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-2.C new file mode 100644 index 00000000000..da8f43bd67d --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-2.C @@ -0,0 +1,21 @@ +// PR c++/81640 +// { dg-do compile } +// { dg-options "-Wshadow=compatible-local" } + +struct A {}; +struct B { operator bool () const { return true; } }; + +template +void +foo () +{ + T d, e; + if (e) + A d; +} + +void +bar () +{ + foo (); +} -- 2.30.2