===================================================================
@@ -26121,7 +26121,8 @@ struct auto_hash : default_hash_traits<tree>
inline hashval_t
auto_hash::hash (tree t)
{
- if (tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t))
+ tree c = PLACEHOLDER_TYPE_CONSTRAINTS (t);
+ if (c && c != error_mark_node)
/* Matching constrained-type-specifiers denote the same template
parameter, so hash the constraint. */
return hash_placeholder_constraint (c);
@@ -26880,50 +26881,53 @@ do_auto_deduction (tree type, tree init, tree auto
/* Check any placeholder constraints against the deduced type. */
if (flag_concepts && !processing_template_decl)
- if (tree constr = 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
- we check using the extra arguments. */
- gcc_assert (TREE_CODE (constr) == CHECK_CONSTR);
- tree cargs = CHECK_CONSTR_ARGS (constr);
- if (TREE_VEC_LENGTH (cargs) > 1)
- {
- cargs = copy_node (cargs);
- TREE_VEC_ELT (cargs, 0) = TREE_VEC_ELT (targs, 0);
- }
- else
- cargs = targs;
- if (!constraints_satisfied_p (constr, cargs))
- {
- if (complain & tf_warning_or_error)
- {
- auto_diagnostic_group d;
- switch (context)
- {
- case adc_unspecified:
- case adc_unify:
- error("placeholder constraints not satisfied");
- break;
- case adc_variable_type:
- case adc_decomp_type:
- error ("deduced initializer does not satisfy "
- "placeholder constraints");
- break;
- case adc_return_type:
- error ("deduced return type does not satisfy "
- "placeholder constraints");
- break;
- case adc_requirement:
- error ("deduced expression type does not satisfy "
- "placeholder constraints");
- break;
- }
- diagnose_constraints (input_location, constr, targs);
- }
- return error_mark_node;
- }
- }
+ {
+ tree constr = PLACEHOLDER_TYPE_CONSTRAINTS (auto_node);
+ if (constr && constr != error_mark_node)
+ {
+ /* Use the deduced type to check the associated constraints. If we
+ have a partial-concept-id, rebuild the argument list so that
+ we check using the extra arguments. */
+ gcc_assert (TREE_CODE (constr) == CHECK_CONSTR);
+ tree cargs = CHECK_CONSTR_ARGS (constr);
+ if (TREE_VEC_LENGTH (cargs) > 1)
+ {
+ cargs = copy_node (cargs);
+ TREE_VEC_ELT (cargs, 0) = TREE_VEC_ELT (targs, 0);
+ }
+ else
+ cargs = targs;
+ if (!constraints_satisfied_p (constr, cargs))
+ {
+ if (complain & tf_warning_or_error)
+ {
+ auto_diagnostic_group d;
+ switch (context)
+ {
+ case adc_unspecified:
+ case adc_unify:
+ error("placeholder constraints not satisfied");
+ break;
+ case adc_variable_type:
+ case adc_decomp_type:
+ error ("deduced initializer does not satisfy "
+ "placeholder constraints");
+ break;
+ case adc_return_type:
+ error ("deduced return type does not satisfy "
+ "placeholder constraints");
+ break;
+ case adc_requirement:
+ error ("deduced expression type does not satisfy "
+ "placeholder constraints");
+ break;
+ }
+ diagnose_constraints (input_location, constr, targs);
+ }
+ return error_mark_node;
+ }
+ }
+ }
if (processing_template_decl && context != adc_unify)
outer_targs = current_template_args ();
===================================================================
@@ -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" }