This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/67108 (ICE with constexpr and tree dumps)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 12 Aug 2015 18:30:20 +0100
- Subject: C++ PATCH for c++/67108 (ICE with constexpr and tree dumps)
- Authentication-results: sourceware.org; auth=none
We can't do tsubsting once cgraph starts throwing away front end
information; use the at_eof flag to communicate that we've reached that
point.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 61a9d0354261705979003d15ebd7c97605d6dc2e
Author: Jason Merrill <jason@redhat.com>
Date: Wed Aug 12 15:54:06 2015 +0100
PR c++/67108
* decl2.c (c_parse_final_cleanups): Set at_eof to 2 at end.
* error.c (dump_template_bindings): Don't tsubst in that case.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 78fd4af..ab6b3ec 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4797,7 +4797,8 @@ extern GTY(()) vec<tree, va_gc> *local_classes;
#endif /* !defined(NO_DOLLAR_IN_LABEL) || !defined(NO_DOT_IN_LABEL) */
-/* Nonzero if we're done parsing and into end-of-file activities. */
+/* Nonzero if we're done parsing and into end-of-file activities.
+ Two if we're done with front-end processing. */
extern int at_eof;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 068d79c..8e7a453 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4846,6 +4846,9 @@ c_parse_final_cleanups (void)
timevar_stop (TV_PHASE_DEFERRED);
timevar_start (TV_PHASE_PARSING);
+
+ /* Indicate that we're done with front end processing. */
+ at_eof = 2;
}
/* Perform any post compilation-proper cleanups for the C++ front-end.
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index ae3e092..faf8744 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -339,6 +339,11 @@ dump_template_bindings (cxx_pretty_printer *pp, tree parms, tree args,
&& !DECL_LANG_SPECIFIC (current_function_decl))
return;
+ /* Don't try to do this once cgraph starts throwing away front-end
+ information. */
+ if (at_eof >= 2)
+ return;
+
FOR_EACH_VEC_SAFE_ELT (typenames, i, t)
{
if (need_semicolon)
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-targ3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ3.C
new file mode 100644
index 0000000..d1e4482
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-targ3.C
@@ -0,0 +1,40 @@
+// PR c++/67108
+// { dg-do compile { target c++11 } }
+
+template < typename, typename > struct is_same;
+template < typename T > struct is_same <T, T >
+{
+ enum
+ {
+ value = true
+ }
+ ;
+ constexpr bool operator () ()
+ {
+ return value;
+ }
+}
+ ;
+template < bool, typename = void >struct enable_if;
+template < typename T > struct enable_if <true, T >
+{
+ typedef T type;
+}
+ ;
+struct A;
+template < typename, typename = void >struct F;
+template < typename X > struct F <X, typename enable_if < is_same < X, A >
+{
+}
+ () >::type >
+{
+ template < typename MakeDependent > F (MakeDependent)
+ {
+ }
+}
+;
+
+int main ()
+{
+ F < A > (1);
+}