re PR c++/85065 ([concepts] ICE with invalid use of a concept)
authorPaolo Carlini <paolo@gcc.gnu.org>
Tue, 18 Sep 2018 16:35:27 +0000 (16:35 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 18 Sep 2018 16:35:27 +0000 (16:35 +0000)
/cp
2018-09-18  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/85065
* cp-tree.h (NON_ERROR): New.
* pt.c (auto_hash::hash): Use it.
(do_auto_deduction): Likewise.

/testsuite
2018-09-18  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/85065
* g++.dg/concepts/pr85065.C: New.

From-SVN: r264402

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/concepts/pr85065.C [new file with mode: 0644]

index f73ea2a1f3eb4b72b0740023dce12425b4d5dac3..fdc1247746deda1742f8aafec95b618d15ebd6c2 100644 (file)
@@ -1,3 +1,10 @@
+2018-09-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/85065
+       * cp-tree.h (NON_ERROR): New.
+       * pt.c (auto_hash::hash): Use it.
+       (do_auto_deduction): Likewise.
+
 2018-09-18  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/86881
index 6cd6e5f5886f6a76f1955d52cd7905c5aabe37a8..2203e92dda88f48848999fbb65f8244e5494eac5 100644 (file)
@@ -1877,6 +1877,8 @@ struct GTY(()) language_function {
 /* In parser.c.  */
 extern tree cp_literal_operator_id (const char *);
 
+#define NON_ERROR(NODE) ((NODE) == error_mark_node ? NULL_TREE : (NODE))
+
 /* TRUE if a tree code represents a statement.  */
 extern bool statement_code_p[MAX_TREE_CODES];
 
index 892a387cbc56e92175553485023e2318e035ac9d..b8b6545434b383d2a666d8b38f95b27a3ab424c4 100644 (file)
@@ -26121,7 +26121,7 @@ struct auto_hash : default_hash_traits<tree>
 inline hashval_t
 auto_hash::hash (tree t)
 {
-  if (tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t))
+  if (tree c = NON_ERROR (PLACEHOLDER_TYPE_CONSTRAINTS (t)))
     /* Matching constrained-type-specifiers denote the same template
        parameter, so hash the constraint.  */
     return hash_placeholder_constraint (c);
@@ -26880,7 +26880,7 @@ do_auto_deduction (tree type, tree init, tree auto_node,
 
   /* Check any placeholder constraints against the deduced type. */
   if (flag_concepts && !processing_template_decl)
-    if (tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (auto_node))
+    if (tree constr = NON_ERROR (PLACEHOLDER_TYPE_CONSTRAINTS (auto_node)))
       {
         /* Use the deduced type to check the associated constraints. If we
            have a partial-concept-id, rebuild the argument list so that
index 3c96db42b62d74a2660572fae034e5baa3fb322a..7a7a7c24563008095b15f8e6f152fd960922747e 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-18  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/85065
+       * g++.dg/concepts/pr85065.C: New.
+
 2018-09-18  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        PR testsuite/87339
 
 2018-09-18  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
-    * gcc.target/aarch64/spellcheck_1.c:
-    Make architecture suggestion optional.
-    * gcc.target/aarch64/spellcheck_4.c:
-    Likewise.
+       * gcc.target/aarch64/spellcheck_1.c:
+       Make architecture suggestion optional.
+       * gcc.target/aarch64/spellcheck_4.c:
+       Likewise.
 
 2018-09-18  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
diff --git a/gcc/testsuite/g++.dg/concepts/pr85065.C b/gcc/testsuite/g++.dg/concepts/pr85065.C
new file mode 100644 (file)
index 0000000..861a838
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-do compile { target c++14 } }
+// { dg-additional-options "-fconcepts" }
+
+template<int> concept bool C = true;
+
+C c = 0;  // { dg-error "invalid reference to concept" }