re PR c++/81640 (ICE in lookup_fnfields_slot_nolazy w/ -Wshadow=compatible-local)
authorJakub Jelinek <jakub@redhat.com>
Wed, 2 Aug 2017 07:28:21 +0000 (09:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 2 Aug 2017 07:28:21 +0000 (09:28 +0200)
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
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/Wshadow-compatible-local-2.C [new file with mode: 0644]

index 03a9d0864084ab52774e18ecdf7f428ba9a8f690..8be42940bd8d998b989e61a857b385542ef45a56 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-02  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <jason@redhat.com>
 
        * decl.c (declare_global_var): Set DECL_CONTEXT.
index e74d48daa8b1dcc539bad19fdb3ee4afbdef2ddb..f633fa5ad91f48b79b34bf2e8453b98305629287 100644 (file)
@@ -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);
index 41ccd0df84445370cb98514696f78ea196579d35..142e4de0e735681289d3deec94fd87581fdc50a6 100644 (file)
@@ -1,5 +1,8 @@
 2017-08-02  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..da8f43b
--- /dev/null
@@ -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 <typename T>
+void
+foo ()
+{
+  T d, e;
+  if (e)
+    A d;
+}
+
+void
+bar ()
+{
+  foo <B> ();
+}