This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix ICE with PARM_DECL with incomplete type (PR c++/77338)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 29 Aug 2016 21:46:12 +0200
- Subject: [C++ PATCH] Fix ICE with PARM_DECL with incomplete type (PR c++/77338)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
In r239289 you've done something similar for the VAR_DECL etc. case, but
for PARM_DECL we can still call is_really_empty_class on incomplete types
and ICE because TYPE_BINFO is NULL.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2016-08-29 Jakub Jelinek <jakub@redhat.com>
PR c++/77338
* constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only
call is_really_empty_class on complete types.
* g++.dg/cpp0x/decltype-77338.C: New test.
--- gcc/cp/constexpr.c.jj 2016-08-12 17:33:42.000000000 +0200
+++ gcc/cp/constexpr.c 2016-08-29 14:26:50.342319322 +0200
@@ -3747,7 +3747,8 @@ cxx_eval_constant_expression (const cons
/* Defer in case this is only used for its type. */;
else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
/* Defer, there's no lvalue->rvalue conversion. */;
- else if (is_really_empty_class (TREE_TYPE (t)))
+ else if (COMPLETE_TYPE_P (TREE_TYPE (t))
+ && is_really_empty_class (TREE_TYPE (t)))
{
/* If the class is empty, we aren't actually loading anything. */
r = build_constructor (TREE_TYPE (t), NULL);
--- gcc/testsuite/g++.dg/cpp0x/decltype-77338.C.jj 2016-08-29 14:42:31.974306247 +0200
+++ gcc/testsuite/g++.dg/cpp0x/decltype-77338.C 2016-08-29 14:41:12.000000000 +0200
@@ -0,0 +1,7 @@
+// PR c++/77338
+// { dg-do compile { target c++11 } }
+
+struct S;
+
+template <typename>
+auto f (S s) -> decltype (s (s)); // { dg-error "no match for call to" }
Jakub