C++ PATCH for c++/84551, ICE with concepts and DEBUG_BEGIN_STMT

Message ID CADzB+2kKF_V3XiUmZtnVcRGHrMT6X0qFzwWTnRKn_N3Bv1TPQA@mail.gmail.com
State New
Headers show
Series
  • C++ PATCH for c++/84551, ICE with concepts and DEBUG_BEGIN_STMT
Related show

Commit Message

Jason Merrill Feb. 26, 2018, 7:09 p.m.
DEBUG_BEGIN_STMT was confusing the concepts machinery, and it isn't
useful in concepts, which are never expanded.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 8a2a7e8672b17af0231c82b6f3d4429efddec0d6
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Feb 26 13:48:34 2018 -0500

            PR c++/84551 - ICE with concepts and -g.
    
            * parser.c (add_debug_begin_stmt): Do nothing in a concept.

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4fa546a086c..f305c9c7eba 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10699,6 +10699,9 @@  add_debug_begin_stmt (location_t loc)
 {
   if (!MAY_HAVE_DEBUG_MARKER_STMTS)
     return;
+  if (DECL_DECLARED_CONCEPT_P (current_function_decl))
+    /* A concept is never expanded normally.  */
+    return;
 
   tree stmt = build0 (DEBUG_BEGIN_STMT, void_type_node);
   SET_EXPR_LOCATION (stmt, loc);
diff --git a/gcc/testsuite/g++.dg/concepts/debug1.C b/gcc/testsuite/g++.dg/concepts/debug1.C
new file mode 100644
index 00000000000..eeb63654243
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/debug1.C
@@ -0,0 +1,10 @@ 
+// PR c++/84551
+// { dg-options "-g -O -std=c++17 -fconcepts" }
+
+template<typename> concept bool C() { return true; }
+
+template<template<typename T> requires C<T>() class> struct A {};
+
+template<typename> requires true struct B {};
+
+A<B> a;