1 2015-05-22 Andrew Sutton <andrew.n.sutton@gmail.com>
3 Fix regression caused by null de-reference.
4 * gcc/cp/decl.c (xref_tag_1): Check that current_template_parms
5 is non-null before accessing constraints.
7 2015-05-19 Andrew Sutton <andrew.n.sutton@gmail.com>
9 Handle nested requirements with type errors.
10 * gcc/cp/constraint.cc (constraint_p): Admit error_mark_node
11 as a valid, but never satisfied, constraint.
12 (normalize_constraint): Handle the error_mark_node case.
13 * gcc/cp/cxx-pretty-print.c (pp_cxx_constraint): Likewise.
14 * gcc/testsuite/g++.dg/concepts/fn10.C: New test case.
16 2015-05-19 Andrew Sutton <andrew.n.sutton@gmail.com>
18 Stop template processing during constraint satisfication.
19 * gcc/cp/constraint.cc (satisfy_constraint): Rename to
20 satisfy_constraint_1 and assert that we are not processing
21 template declarations.
22 (satisfy_*_constraint): Use satisfy_constraint_1.
23 (satisfy_constraint): Turn off template processing.
24 * gcc/testsuite/g++.dg/concepts/fn10.C: New.
26 2015-05-19 Andrew Sutton <andrew.n.sutton@gmail.com>
28 Handle naked non-type template arguments as constraints.
29 * gcc/cp/constraint.cc (xform_misc): Removed.
30 (transform_expr): All misc tree classes are atomic constraints.
31 * gcc/testsuite/g++.dg/concepts/req1.C: Add new test cases.
33 2015-05-18 Andrew Sutton <andrew.n.sutton@gmail.com>
35 Fix long-standing regression in template introductions.
36 * gcc/cp/parser.c (cp_parser_template_declaration_after_export):
38 (cp_parser_template_parameter_list): Remove #ifdeffing.
39 (cp_parser_member_declaration): Check for template introductions.
40 (cp_parser_template_declaration_after_parameters): New. Parse
41 a template declaration following the declaration or introduction
42 of template parameters.
43 (cp_parser_template_introduction): Save and restore scopes when
44 tentatively parsing a template introduction. Update diagnostics.
45 (cp_parser_explicit_template_declaration): Renamed from
46 cp_parser_template_declaration_after_export. Parse a template
47 declartion that begins with the template keyword. Use
48 cp_parser_template_declaration_after_parameters to parse the
49 declaration after parsing the header.
50 (cp_parser_template_declaration_after_export): Use either
51 cp_parser_template_introduction or
52 cp_parser_explicit_template_declaration.
53 * gcc/testsuite/g++.dg/concepts/intro4: Remove spurios diagnostic.
54 * gcc/testsuite/g++.dg/concepts/intro6: New.
56 2015-05-08 Andrew Sutton <andrew.n.sutton@gmail.com>
59 * gcc/cp/cp-tree.h (get_function_declarator): New.
60 * gcc/cp/decl.c (get_trailing_requires_clause): Use
61 get_function_declarator.
62 * gcc/cp/parser.c (function_declarator_p): Likewise.
63 (cp_parser_declarator): Stop invoking undefined behavior
64 and install the requires clause on the found function
66 * gcc/testsuite/g++.dg/concepts/pr66091.C: New.
68 2015-05-08 Andrew Sutton <andrew.n.sutton@gmail.com>
70 Addressing review comments.
71 * gcc/cp/call.c (build_new_function_call): Don't check for
72 template parameters when we're not processing a template decl.
73 * gcc/cp/constraint.cc (function_concept_check_p): Use
75 (satisfy_expression_constraint): Move sentinel into cp-tree.h.
76 * gcc/cp/parser.c (cp_parser_declarator): Use function_declarator_p.
77 * gcc/cp/cp-tree.h (struct deferring_access_check_sentinel): Moved
79 * gcc/cp/semantics: (finish_call_expr) Don't remove constraints.
81 2015-05-08 Andrew Sutton <andrew.n.sutton@gmail.com>
83 Use the substituted type, not the deduced arguments, to
84 check placeholder constraints.
85 * gcc/cp/pt.c (do_auto_deduction): Check constraints using
86 the deduced type and not the deduced arguments.
87 (tsubst): Don't substitute through constraints.
88 * gcc/cp/cxx-pretty-print.c (cxx_pretty_printer::expression):
89 Print trait expressions.
90 (pp_cxx_implicit_conversion_constraint,
91 pp_cxx_argument_deduction_constraint): Clean up printing.
92 * gcc/testsuite/g++.dg/concepts/placeholder2.C: Update tests
93 to require extra substitutions.
95 2015-05-07 Andrew Sutton <andrew.n.sutton@gmail.com>
97 Implement argument deduction constraints.
98 * gcc/cp/cp-tree.def (DEDUCT_CONSTR): Add a third operand.
99 * gcc/cp/cp-tree.h (auto_deduction_context): New. Flags to control
100 diagnostics in auto deduction.
101 (do_auto_deduction): New overload to allow for control of diagnostics.
102 (tsubst_constraint): Make extern.
103 * gcc/cp/pt.c (tsubst): Propagate constraints for place holders.
104 (do_auto_deduction): New overload that calls the expanded version
106 (do_auto_deduction): Control diagnostics with tf_subst_flags and
107 auto_deduction_context.
108 (do_auto_deduction): Only check constraints for when not using
110 * gcc/cp/constraint.cc (xform_compound_requirement): Build argument
111 deduction constraints.
112 (xform_atomic): Don't check the types of dependent expressions,
113 even when not processing templates.
114 (satisfy_argument_deduction_constraint): Implement this.
115 * gcc/testsuite/g++.dg/concepts/placeholder1.C: Add tests for
116 more complex failures.
117 * gcc/testsuite/g++.dg/concepts/placeholder2.C: New.
119 2015-05-06 Andrew Sutton <andrew.n.sutton@gmail.com>
121 Initial implementation of constrained-type-specifiers for variable
122 declarations. Also updating documentation and style.
123 * gcc/cp/cp-tree.h (make_constrained_auto): New.
124 (evaluate_constraints): New.
125 (check_constraint_epression): Renamed and made static.
126 * gcc/cp/pt.c (do_auto_deduction): Check constraints on
127 constrained placeholders before forming the type.
128 * gcc/cp/parser.c (cp_parser_postfix_expression): Don't
129 allow constrained-type-specifiers within the first term
130 of a postfix expression.
131 (cp_parser_allows_constrained_type_specifier): Removed.
132 (cp_maybe_constrained_type_specifier): Don't process
133 nodes as constrained type specifiers unless they look like
134 constrianed type specifiers, and only when they are allowed.
135 Also, support constrained auto for placeholders. Renamed
136 variables to better reflect usage.
137 gcc/cp/parser.h (struct cp_parser): New member
138 prevent_constrained_type_specifiers.
139 gcc/cp/decl.c (grokfndecl): Remove commented code.
140 gcc/cp/constraint.cc (deduce_constrained_parameter): New.
141 Actually check that template arguments match the concept's
143 (deduce_constrained_parameter): Use deduce_constrained_parameter.
144 (make_constrained_auto): New. Construct an auto with an
146 (check_*_constraint): Renamed to satisfy_*_constraint.
147 (satisfy_constraint): New. Simplify usage in evaluation functions.
148 (evaluate_constraints): New. Normalize and evaluate a constraint.
149 (constraints_satisfied_p): Allow a constraint to be used as
150 an argument in addition to declaraitons.
151 (constraint_expression_satisfied_p): Renamed from
152 check_constraint_expression.
153 (diagnose_*): Use constraint_expression_satisfied_p.
154 (diagnose_decl_constraint): New.
155 (diagnose_constraint): Allow the argument to be a constraint
156 in addition to a declaration.
157 * gcc/testsuite/g++.dg/concepts/mem-concept.C: Renamed to
158 member-concept.C. Updated tests to reflect actual errors.
159 * gcc/testsuite/g++.dg/concepts/mem-concept-err.C: Removed,
160 because it is redundant.
161 * gcc/testsuite/g++.dg/concepts/var-concept5.C: Update error messages.
162 * gcc/testsuite/g++.dg/concepts/placeholder1.C: New.
164 2015-05-05 Andrew Sutton <andrew.n.sutton@gmail.com>
166 Fixing errors in the invention of constrained placeholders
167 and bringing the implementation more into line with the
168 wording of the TS. Also, rewrite comments in C style.
169 * gcc/cp/cp-tree.def (INTRODUCED_PARM_DECL): Renamed to
171 * gcc/cp/cp-tree.h (INTRODUCED_PACK_P): Renamed to
173 (IS_INTRODUCED_PACK): Removed.
174 * cp-objcp-common.c (cp_common_init_ts): Use WILDCARD_DECL.
175 * gcc/cp/pt.c (convert_placeholder_argument): Renamed to
176 convert_wildcard_argument.
177 (coerce_template_parameter_pack): Update for removed macro.
178 gcc/cp/parser.c (cp_parser_introduction_list): Use WILDCARD_DECL.
179 (cp_maybe_constrained_type_specifier): Likewise.
180 (get_concept_from_constraint): Handle VAR_DECLs.
181 gcc/cp/constraint.cc (contains_wildcard_p): New.
182 (build_variable_check): New. Finish processing references to
183 variable templates if the template-id doesn't have wildcards.
184 (build_concept_check_arguments): New. Factor argument construction
185 into a separate function.
186 (build_template_id_check): New. Like build_concept_check, but
187 guarantees preservation of template-ids.
188 (build_concept_check): Use build_variable_check. Refacor to
189 use build_concept_check_arguments.
190 (process_introduction_parm): Use WILDCARD_DECL.
191 * gcc/testsuite/g++.dg/concepts/equiv2.C: Update test.
193 2015-05-04 Andrew Sutton <andrew.n.sutton@gmail.com>
196 * gcc/cp/parser.c (cp_parser_type_requirement): Unwrap alias
197 declarations so they can be checked correctly.
198 * gcc/testsuite/g++.dg/concepts/pr65854.C: New.
200 2015-04-22 Andrew Sutton <andrew.n.sutton@gmail.com>
203 * gcc/cp/cp-tree.h (function_concept_check_p): New.
204 * gcc/cp/call.c (build_new_function_call): Don't evaluate
205 concepts while processing a template.
206 * gcc/cp/constraint.cc (function_concept_check_p): New.
207 * gcc/cp/pt.c (finish_template_variable): Don't evaluate
208 concepts while processing a template.
209 (instantiation_dependent_r): Treat all calls to function
210 concepts as instantiation dependent.
211 * gcc/testsuite/g++.dg/concepts/pr65848.C: New.
212 * gcc/testsuite/g++.dg/concepts/req4.C: Remove extra errors.
213 * gcc/testsuite/g++.dg/concepts/req5.C: Remove extra errors.
215 2015-04-22 Andrew Sutton <andrew.n.sutton@gmail.com>
217 Compare constrained partial specializations structurally.
218 * gcc/pt.c (process_partial_specialization): Don't use a
219 canonical type for constrained partial template specializations.
220 Compare structurally to avoid ICE's when specializations resolve
223 2015-04-20 Andrew Sutton <andrew.n.sutton@gmail.com>
226 * gcc/cp/constraint.cc (tsubst_simple_requirement): Substitute
227 in a template-processing context to avoid doing full resolution
228 on types and expressions.
229 (tsubst_type_requirement): Likewise.
230 (tsubst_compound_requirement): Likewise.
231 (tsubst_nested_requirement): Likewise.
232 * gcc/testsuite/g++.dg/concepts/pr65681.C: New.
233 * gcc/testsuite/g++.dg/concepts/req2.C: Remove check for spurious
236 2015-04-20 Andrew Sutton <andrew.n.sutton@gmail.com>
238 Improve pretty printing output for constraints
239 * gcc/cp/error.c (dump_expr): Print predicate constraints
240 just like other constraints.
241 * gcc/cp/cxx-pretty-print.c (pp_cxx_requirement): Add missing
243 (pp_cxx_requirement_list): Print requirements inline instead
245 (pp_cxx_requirement_body): Don't print a parameter list if
246 there are no parameters.
247 (pp_cxx_nested_requirement): Be less obtuse.
248 (pp_cxx_expression_constraint): Likewise.
249 (pp_cxx_type_constraint) Likewise.
250 (pp_cxx_implicit_conversion_constraint): Likewise.
251 (pp_cxx_argument_deduction_constraint): Likewise.
252 (pp_cxx_parameterized_constraint): Likewise.
253 (pp_cxx_conjunction): Print spaces explicitly.
254 (pp_cxx_disjunction): Likewise.
256 2015-04-17 Andrew Sutton <andrew.n.sutton@gmail.com>
258 Support requires-expressions for variable concepts.
259 * gcc/cp/parser.c (cp_parser_requires_expression): Parse
260 the parameters and body as unevaluated operands.
261 * gcc/cp/pt.c (value_dependent_expression_p): Make all
262 requires-expressions value dependent so we don't try to
263 initialize concepts as if they were actually variables.
264 * gcc/cp/tree.cp (cp_tree_equal): Remove debugging code.
265 * gcc/testsuite/g++.dg/concepts/var-concept1.C: Add tests
268 2015-04-14 Andrew Sutton <andrew.n.sutton@gmail.com>
270 Fix bootstrap regression.
271 * gcc/cp/parser.c (cp_maybe_partial_concept_id): Remove
274 2015-04-13 Andrew Sutton <andrew.n.sutton@gmail.com>
276 Handle partial-concept-ids for variable templates
277 * gcc/cp/parser.c (cp_parser_template_id): Factor the check for
278 variable templates into a new branch that preceeds the check
279 for variable templates and function templates.
280 * gcc/testsuite/g++.dg/concepts/partial.C: Renamed.
281 * gcc/testsuite/g++.dg/concepts/partial-concept-id2.C: New.
283 2015-04-06 Andrew Sutton <andrew.n.sutton@gmail.com>
285 * gcc/cp/constraint.cc (lift_variable_concept): Coerce template
286 arguments before substituting into the initializer.
287 * gcc/cp/pt.c (coerce_template_parms): New overload that accepts
289 * gcc/cp/cp-tree.h (coerce_template_parms): New declaration.
290 * gcc/testsuite/g++.dg/concepts/var-concept5.C: New.
292 2015-04-06 Andrew Sutton <andrew.n.sutton@gmail.com>
294 * gcc/cp/constriant.cc (check_pack_expansion): Don't check
295 same_type_p if the type is null.
296 * gcc/cp/pt.c (process_partial_specialization): Don't allow
297 specialization of variable concepts.
298 * gcc/testsuite/g++.dg/concepts/var-concepts[1-3].C: Renamed to
300 * gcc/testsuite/g++.dg/concepts/var-concept4.C: New.
302 2015-04-03 Andrew Sutton <andrew.n.sutton@gmail.com>
305 * gcc/cp/tree.c (cp_tree_equal): Compare type declrations when
306 ordering constraints.
307 * gcc/testsuite/g++.dg/concepts/pr65635: New.
309 2015-04-03 Andrew Sutton <andrew.n.sutton@gmail.com>
312 * gcc/cp/pt.c (tsubst_decl): Don't try to manage specializations
313 for non-dependent, simple type declarations in namespace scope
314 because they don't have C++ language extensions.
315 * gcc/testsuite/g++.dg/concepts/pr65636: New.
317 2015-04-03 Andrew Sutton <andrew.n.sutton@gmail.com>
320 * gcc/cp/except.c (check_noexcept_r): Check the function type
321 and not the return type for (TYPE_NOTHROW_P).
322 * gcc/cp/parser.c (cp_parser_check_for_invalid_template_id): Remove
323 stray debugging code.
324 * gcc/testsuite/g++.dg/concepts/pr65634: New.
326 2015-04-02 Andrew Sutton <andrew.n.sutton@gmail.com>
328 Fixing constraint processing bugs.
329 * gcc/cp/constraint.cc (check_logical_expr): Use build_x_binary_op
330 so that the c-common doesn't try to fold requires-expressions.
331 * gcc/cp/constexpr.c (cxx_eval_constant_expression): The value
332 of a requires clause is true iff its constraints are satisfied.
333 This lets us check negated requires-expressions.
334 * gcc/testsuite/g++.dg/concepts/req4.C: Update diagnostics
335 * gcc/testsuite/g++.dg/concepts/req5.C: Update diagnostics
336 * gcc/testsuite/g++.dg/concepts/req11.C: New.
338 2015-03-27 Andrew Sutton <andrew.n.sutton@gmail.com>
340 Trying again with PR65575.
341 * gcc/cp/parser.c (cp_parser_declarator): Search through
342 declarator structure for likely matches for function
344 * gcc/testsuite/g++.dg/concepts/pr65575.C: Update with
347 2015-03-25 Andrew Sutton <andrew.n.sutton@gmail.com>
350 * gcc/cp/parser.c (cp_parser_declarator): Don't emit errors
351 when a trailing requires-clause follows a non-function
353 * gcc/testsuite/g++.dg/concepts/pr65575.C: New.
355 2015-03-25 Andrew Sutton <andrew.n.sutton@gmail.com>
357 Fix scope-squashing error in PR65552.
358 * gcc/cp/parser.C (cp_parser_type_requirement): Save and
359 restore scopes around optional nested name specifier parse.
360 * gcc/testsuite/g++.dg/concepts/pr65552.C: New.
362 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
364 Fix bug in disjunction processing and fix the pretty
365 printing for __is_same_as trait correct.
366 * gcc/cp/constraint.cc (check_disjunction): Don't return
367 false if the first condition fails and the second succeeds.
368 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expr): Print the
369 second argument for __is_same_as.
371 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
373 Make implicit conversion constraints handle usual
374 conversions, not just implicit conversions.
375 * gcc/cp/constraint.cc (check_implicit_conversion_constraint):
376 Use perform_direct_initialization_if_possible to test for
377 converibility instead of can_convert_arg.
378 * gcc/testsuite/g++.dg/concepts/req10.C: New.
380 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
382 Suppress errors regarding deleted functions when
384 * gcc/cp/pt.c (tsubst_baselink): Pass complain flags to
386 * gcc/testsuite/g++.dg/concepts/expression3.C: New.
388 2015-03-22 Andrew Sutton <andrew.n.sutton@gmail.com>
390 Fix regression related to variadic templates, bugs in
391 the handling of access checking, and in the logic solver.
392 * gcc/cp/constraint.cc (declare_constraint_vars): Mark
393 constraint variables.
394 (deferring_access_check_sentinel): Make this a local class
395 of check_expression_constraint.
396 (check_type_constraint): Don't defer access checks. Instead
397 pop deferred access checks if they fail.
398 (finish_requires_expr): Mark constraint variables.
399 * gcc/cp/cp-tree.h (CONSTRAINT_VAR_P): Indicates if a
400 parameter is a constraint variable.
401 * gcc/cp/pt.c (pending_expansion_p): New. Helps determine
402 if a parameter will be expanded during substitution.
403 (tsubst_pack_expansion): For certain expressions pending
404 expansion, do that here.
405 (tsubst_decl): Remove dead code.
406 (tsubst_copy_and_build): Don't add arguments that are
407 pending expansion. Also, don't build expansion when the
408 type is dependent. This was causing a regression in
410 * gcc/cp/logic.cc (proof_state::branch): Don't rely on
411 order of operations. This crashed when built with Clang.
412 * gcc/testsuite/g++.dg/concepts/expression2.C: Update to
415 2015-03-21 Andrew Sutton <andrew.n.sutton@gmail.com>
417 Completely suppress access violations occurring from
419 * gcc/cp/constraint.cc (deferring_access_check_sentinel): New helper
420 class for managing deferred access checks.
421 (check_expression_constraint): Explicitly defer constraint checks.
422 (check_type_constraint): Explicitly defer constraint checks.
423 * gcc/testsuite/g++.dg/concepts/expression3.C: New.
425 2015-03-21 Andrew Sutton <andrew.n.sutton@gmail.com>
427 Fail constraints due to access violations in non-SFINAE
429 gcc/cp/constraint.cc (check_expression_constraint,
430 check_type_constraint): Check for access violations.
431 gcc/cp/pt.c (tsubst_decl): Make sure that template
432 info exists before dereferencing it.
433 * gcc/testsuite/g++.dg/concepts/expression2.C: New.
435 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
437 Fix grammar error type requirements and improve diagnostics
438 for mis-defined function concepts and errors involving pack
440 * gcc/cp/pt.c (determine_specialization). Remove dead code.
441 (lookup_template_class_1): Return an error if constraints
443 * gcc/cp/constraint.cc (lift_function_definition): Don't
444 re-check for empty/erroneous concept definitions.
445 (lift_pack_expansion): Removed. Don't inline patterns so
446 that we can preserve the syntax beneath them.
447 (lift_expression): Don't do anything with pack expansions.
448 (check_function_concept): Specifically check for empty
450 (diagnose_pack_expansion): Diagnose errors in expansions
451 more thoughtfully by determining which arguments are failing
452 their expanded requirements.
453 gcc/cp/parser.c (cp_parser_type_requirement): Accept an
454 optional template keyword before a template-id and
455 parse that as a special case of required type name.
456 gcc/testsuite/g++.dg/concepts/template-parm11.C: Update test
457 for fixed grammar, diagnostics.
459 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
461 Ensure that empty expansions are satisfied.
462 * gcc/cp/constraint.cc (check_pack_expansion): Empty expansions
464 * gcc/testsuite/g++.dg/concepts/template-parm11.C: New.
466 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
468 Fix regression in variadic constraint processing.
469 * gcc/cp/pt.c (tsubst_pack_expansion): Expose declaration.
470 * gcc/cp/constraint.cc: Rename lift_constraints to
471 lift_expression to better reflect what it does.
472 (lift_pack_expansion): New. Handles naked pack expansions
474 (check_pack_expansion): Special handling for checking naked
475 pack expansions in constraints. This eventually be replaced
476 by similar logic for fold expressions.
477 (check_predicate_constraint): Handle pack expansions.
478 * gcc/cp/cp-tree.h (tsubst_pack_expansion): Make this avaialble
481 2015-03-18 Andrew Sutton <andrew.n.sutton@gmail.com>
483 Update variable concept processing to account for changes
484 in variable template syntax.
485 * gcc/cp/constraint.cc (valid_predicate_p): Remove because of
487 (make_predicate_constraint): Likewise.
488 (lift_function_call): Check for use of variables in function
489 calls in constraints.
490 (lift_call_expression): Renamed from lift_call. Specifically
491 check function calls before rewriting the node.
492 (lift_variable_concept). Renamed from lift_var. Remove redundant
494 (lift_variable). New. Accommodates new processing rules for
496 (lift_constraints). Add variable decls to the switch.
497 * gcc/cp/pt.c (finish_variable_template): Don't evaluate
498 for dependent template arguments.
499 (remove_constraints): Remove debugging code.
500 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: Separate out
501 failing test into equiv2.C.
502 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: Update error
504 * gcc/testsuite/g++.dg/concepts/equiv2.C: New.
506 2015-03-18 Andrew Sutton <andrew.n.sutton@gmail.com>
508 Addressing regressions after merge.
509 * gcc/cp/parser.c (cp_parser_template_declaration_after_export):
510 Revert implementation of concept introductions. It was causing
512 * gcc/testsuite/g++.dg/concepts/friend1.C: Update test to account
513 for apparent fix (?) to lookup rules involving friends.
515 2015-03-03 Andrew Sutton <andrew.n.sutton@gmail.com>
517 Rewrite to use new constraint model.
518 * gcc/cp/call.c (add_function_candidate): Use new constraint
520 (build_new_function_call): Evaluate concepts when selected
521 by overload resolution.
522 * gcc/cp/class.c (resolve_address_of_overloaded_function):
523 Use new constraint interface.
524 * gcc/cp/constexpr.c (cxx_eval_constant_expression): Don't
525 try to constexpr evaluate a requires-expression.
526 (potential_constant_expression_1): Stop using old
527 requires/constraint features.
528 gcc/cp/constraint.cc: Much rewriting, reorganization, refactoring
529 to support new constraint/requirement terms.
530 (lift_function_definition): New. Factor lifting code out of
531 lift_call for reuse in evaluate_function_concept.
532 (lift_variable_intializer): New. Factor lifting code out of
533 lift_var for reuse in evaluate_variable_concept.
534 (lift_template_id): Restore checking code for mis-written
536 (lift_requires_expr): Handle these separately.
537 (xform_*_requirement): New. Transform requires-expressions
539 (get/set/remove_constraints, decl_constraints): Move to
540 pt.c to allow for garbage collection.
541 (processing_constraint): Kill this global.
542 (diagnose_*): Update diagnostics to use the new constraint
544 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Remove typing
546 * gcc/cp/cp-tree.def: Add new nodes for requirements and
547 constraints. Remove previous constraint/req nodes.
548 gcc/cp/cp-tree.h (COMPOUND_REQ_NOEXCEPT_P): New.
549 (ICONV_CONSTR_EXPR, ICONV_CONSTR_TYPE): Fix operands.
550 (constraint_p, make_predicate_constraint_p, valid_constraints_p): New.
551 (misc): Remove unused declarations.
552 gcc/cp/cxx-pretty-print.c: Reorganize/rewrite for new constraint
554 (primary_expression, expression): Remove unused nodes, add options
556 gcc/cp/cxx-pretty-print.h: Declare new functions for pretty
558 gcc/cp/decl.c (duplicate_decls): Only reclaim when flag_concepts
560 (grokfndecl): Associate predicate constraints.
561 gcc/cp/decl2.c (mark_used): Don't instantiate concepts.
562 gcc/cp/error.c (dump_expr): Handle new constraints.
563 gcc/cp/method.c (implicitly_declare_fn): Use new constraint
565 gcc/cp/parser.c (make_call_declarator): Pass a requires-clause for
567 (cp_parser_type_name): Take a flag to indicate the presence of
568 a pre-parsed 'typename'.
569 (cp_parser_requires_expression): Move sentinel into function.
570 (cp_parser_type_requirement): Parse type requirements in accordance
572 (cp_parser_compound_requirement): Parse compound requirements in
573 accordance with Concepts TS. Remove constexpr requirements.
574 (cp_parser_template_declaration_after_export): Associate
575 predicate constraints.
576 gcc/cp/pt.c (get_template_for_ordering): New. Extract a template
577 decl from a list of candidates.
578 (lookup_template_class_1): Use new constraint interface.
579 (tsubst_pack_conjunction): Build an expression, not constraints.
580 (tsubst_decl): Only associate constraints when substituting
582 (tsubst): Kill subst rules for old nodes.
583 (most_specialized_partial_spec): Save candidates correctly
584 in the presence of constraints.
585 (always_instantiate_p): Never always instantiate a concept.
586 (type_dependent_expression_p): Requires expressions have type bool.
587 (decl_constraints): Moved from constraint.cc, use hash_table
589 gcc/cp/semantics.c (finish_call_expr): Remove constraints from
590 functions, not overload sets.
591 (finish_template_variable): Evaluate variable concepts by
592 determining satisfaction.
593 gcc/cp/typeck.c (cp_build_function_call_vec): Use new concept
595 gcc/cp/testsuite/g++.dg/concepts/*: Update tests to match syntax,
597 gcc/cp/testsuite/g++.dg/concepts/req1.C: Test requires-expression
600 2015-02-25 Braden Obrzut <admin@maniacsvault.net>
602 * gcc/cp/constraint.cc (lift_operands): New.
603 (lift_call): Lift operands on function calls and don't use
604 tsubst_constraint_expr.
605 (lift_var): Don't use tsubst_constraint_expr.
606 (lift_constraints): Use the returned number of operands for most nodes
607 and also lift from TREE_LISTs.
609 2015-02-17 Braden Obrzut <admin@maniacsvault.net>
611 * gcc/cp/constraint.cc (lift_call): Converted from normalize_call.
612 (lift_var): Converted from normalize_var.
613 (lift_template_id): Converted from normalize_template_id.
614 (lift_constraints): Implemented.
616 2015-02-16 Andrew Sutton <andrew.n.sutton@gmail.com>
618 * gcc/cp/cp-tree.h: (EXPR_CONSTR_EXPR, TYPE_CONSTR_TYPE): Fix
619 typos in macro names.
620 * gcc/cp/constraint.cc: (check_constraint*): New. Rewrite the
621 constraint checking implementation so that it matches the
622 wording and rules in n4377.
624 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
626 * gcc/cp/logic.cc: Rewrite to use new constraint model and
628 * gcc/cp/constraint.cc: Documentation and organization.
630 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
632 * gcc/cp/cp-tree.h (is_constraint): Make static.
634 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
636 Rewrite normalization in terms of constraints.
637 * gcc/cp/cp-tree.h (is_constraint): New.
638 * gcc/cp/constraint.cc (normalize_*): Rewrite the previous normalization
639 model so that it conforms with the specification. Normalization applies
640 to constraints. Transformation of expressions into constraints now
641 happens in two phases: lifting concept definitions, and the actual
643 (tranform_expression, xform_*): New. Define transformation of
644 expressions into constraints.
645 (lift_constraints): New. Stubbed out inlining function.
647 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
649 Start refactoring constraints to match the specification.
650 * gcc/cp/cp-tree.def: Add new TREECODEs for constraints.
651 * gcc/cp/cp-tree.h: Add accessor macros for constraint operands.
653 2015-02-05 Braden Obrzut <admin@maniacsvault.net>
655 * gcc/cp/constexpr.c (potential_constant_expression_1): Readded missing
656 cases from previous merge from trunk.
657 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Restored
658 CPTK_IS_CONVERTIBLE_TO for the time being since the constraint code
660 * gcc/cp/semantics.c (finish_trait_expr): Likewise.
661 * gcc/testsuite/g++.dg/concepts/req9.C: New test.
663 2015-02-03 Braden Obrzut <admin@maniacsvault.net>
665 * gcc/cp/class.c (build_clone): Clone constraints.
666 * gcc/cp/constraint.cc (normalize_atom): Update diagnostic.
667 (normalize_constraints): Return error_mark_node if normalization fails.
668 (get_constraints): Access constraints through hash map.
669 (set_constraints): Set constraints through hash map.
670 (remove_constraints): Access constraints through hash map.
671 (associate_classtype_constraints): New.
672 (init_leading_requirements): Removed.
673 (init_trailing_requirements): Removed.
674 (update_leadng_requirements): Removed.
675 (update_trailing_requirements): Removed.
676 (save_leading_constraints): Removed.
677 (save_trailing_constraints): Removed.
678 (finish_template_constraints): Removed.
679 (build_constraints): New. Builds CONSTRAINT_INFO from requirements.
680 (finish_concept_introduction): Check generated parameters for errors.
681 (tsubst_constraint_info): Update implementation.
682 (equivalent_constraints): Check input types.
683 (subsumes_constraints): Update implementation.
684 (at_least_as_constrained): New. Check if a decl's constraints subsumes
686 (diagnose_constraints): Temporarily simplify diagnostics.
687 * gcc/cp/cp-tree.h (tree_constraint_info): Refactor the way constraints
689 (CI_TEMPLATE_REQS): Renamed from CI_LEADING_REQS.
690 (CI_DECLARATOR_REQS): Renamed from CI_TRAILING_REQS.
691 (CI_ASSOCIATED_CONSTRAINTS): New.
692 (CI_NORMALIZED_CONSTRAINTS): New.
693 (CI_ASSOCIATED_REQS): Removed.
694 (saved_scope): Save template requirements.
695 (current_template_reqs): Removed.
696 (lang_decl_min): Replace requires_clause (trailing requirements) with
697 more generic constraint_info.
698 * gcc/cp/cxx-pretty-print.c (cxx_pretty_printer::declarator): Print
700 (pp_cxx_function_definition): Moved requires clause printing to above.
701 (pp_cxx_init_declarator): Likewise.
702 (pp_cxx_template_declaration): Update implementation to get
703 requirements from CONSTRAINT_INFO.
704 * gcc/cp/decl.c (duplicate_decls): Remove constraints before reclaiming
706 (is_class_template_or_specialization): New.
707 (get_leading_constraints): Removed.
708 (adjust_fn_constraints): Removed.
709 (grokfndecl): Update implementation to other changes.
710 (get_trailing_requires_clause): New.
711 (grokdeclarator): Pass trailing requires clause to grokfndecl.
712 (xref_tag_1): Check overload constraints.
713 * gcc/cp/error.c (dump_template_decl): Print requires clause.
714 (dump_function_decl): Update implementation for accessing requirements.
715 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Update
716 CI_ASSOCIATED_REQS usage.
717 * gcc/cp/method.c (implicitly_declare_fn): Copy constraints of
718 inherited constructors.
719 * gcc/cp/parser.c (cp_parser_lambda_expression): Remove now unneeded
720 template requirements saving.
721 (cp_parser_type_parameter): Likewise.
722 (cp_parser_template_argument_list): Unwrap template_template_parms when
723 produced by short hand notation with function concepts.
724 (cp_parser_alias_declaration): Attach constraints to aliases.
725 (cp_manage_requirements): Removed.
726 (cp_parser_trailing_requirements_clause): Renamed from
727 cp_parser_trailing_requirements.
728 (cp_parser_init_declarator): Removed now unneeded requirements saving.
729 (cp_parser_basic_declarator): Separated from cp_parser_declarator.
730 (cp_parser_declarator): Parses trailing requires clause if
731 cp_parser_basic_declarator succeeds.
732 (cp_parser_class_specifier_1): Associate constaints with type.
733 (cp_parser_member_declaration): Remove unneeded template requirement
735 (cp_parser_template_declaration_after_export): Likewise.
736 (cp_parser_single_declaration): Associate constraints.
737 (cp_parser_late_parsing_for_member): Remove unneeded template
739 (synthesize_implicit_template_parm): Likewise.
740 * gcc/cp/pt.c (maybe_new_partial_specialization): Update
742 (process_template_parm): Removed unneeded template requirement saving.
743 (build_template_decl): Handle constraints.
744 (process_partial_specialization): Update constraint access and check
745 that specialization is more specialized.
746 (push_template_decl_real): Update constraint access.
747 (add_inherited_template_parms): Removed constraint handling.
748 (tsubst_pack_conjuction): Update implemenation.
749 (tsubst_decl): Changed constraint propagation.
750 (more_specialized_fn): Update constraint access.
751 (most_specialized_partial_spec): Update constraint access.
752 * gcc/cp/ptree.c (cxx_print_xnode): Update constraint access.
753 * gcc/cp/semantics.c (finish_call_expr): Remove constraints.
754 (finish_template_template_parm): Update constraint access.
755 * gcc/testsuite/g++.dg/concepts/alias4.C: Mark xfail.
756 * gcc/testsuite/g++.dg/concepts/class.C: Check for escape hatch.
757 * gcc/testsuite/g++.dg/concepts/class6.C: Added diagnostic.
758 * gcc/testsuite/g++.dg/concepts/inherit-ctor1.C: Improved test case.
759 * gcc/testsuite/g++.dg/concepts/inherit-ctor2.C: Updated diagnostic.
760 * gcc/testsuite/g++.dg/concepts/inherit-ctor4.C: Updated diagnostic.
761 * gcc/testsuite/g++.dg/concepts/intro4.C: Updated diagnostics.
762 * gcc/testsuite/g++.dg/concepts/req4.C: Updated diagnostic.
763 * gcc/testsuite/g++.dg/concepts/req5.C: Updated diagnostic.
765 2014-12-29 Jason Merrill <jason@redhat.com>
767 * gcc/cp/pt.c (type_dependent_expression_p): Remove obsolete use of
769 (convert_template_argument): Likewise.
771 2014-11-15 Braden Obrzut <admin@maniacsvault.net>
773 * gcc/cp/constraint.cc (resolve_constraint_check): Move definition
775 (normalize_template_id): Use expression location if available when
776 informing about missing parentheses.
777 (build_requires_expr): Added comment.
778 (diagnose_var): Clarified comment.
779 * gcc/cp/decl.c (check_concept_refinement): Remove outdated comment
780 regarding variable concepts.
781 (grokfndecl): Ensure that all concept declarations are definitions.
782 (grokdeclarator): Remove outdated comment regarding variable concepts.
783 * gcc/cp/parser.c (cp_parser_introduction_list): Use vec for temporary
784 list instead of a TREE_LIST.
785 (get_id_declarator): Renamed from cp_get_id_declarator.
786 (get_unqualified_id): Renamed from cp_get_identifier.
787 (is_constrained_parameter): Renamed from cp_is_constrained_parameter.
788 (cp_parser_check_constrained_type_parm): Renamed from
789 cp_check_constrained_type_parm.
790 (cp_parser_constrained_type_template_parm): Renamed from
791 cp_constrained_type_template_parm.
792 (cp_parser_constrained_template_template_parm): Renamed from
793 cp_constrained_template_template_parm.
794 (constrained_non_type_template_parm): Renamed from
795 cp_constrained_non_type_tmeplate_parm.
796 (finish_constrained_parameter): Renamed from
797 cp_finish_constrained_parameter.
798 (maybe_type_parameter): Renamed from cp_maybe_type_parameter.
799 (declares_type_parameter): Renamed from cp_declares_type_parameter.
800 (declares_type_template_parameter): Renamed from
801 cp_declares_type_template_parameter.
802 (declares_template_template_parameter): Renamed from
803 cp_declares_template_template_parameter.
804 (cp_parser_type_parameter): Call
805 cp_parser_default_type_template_argument and
806 cp_parser_default_template_template_argument which were already
807 factored out from this function.
808 (cp_maybe_constrained_type_specifier): Use the new INTRODUCED_PARM_DECL
809 instead of PLACEHOLDER_EXPR.
810 (cp_parser_requires_expr_scope): Remove old comment and change
811 destructor to use pop_bindings_and_leave_scope.
812 (cp_parser_requires_expression): Remove old comment.
813 (get_concept_from_constraint): Remove old comment.
814 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Changed expected
815 errors now that missing concept definitions are diagnosed earlier.
817 2014-11-11 Jason Merrill <jason@redhat.com>
819 * gcc/cp/call.c (add_function_candidate): Move constraint check after
822 * gcc/cp/class.c (get_member_fn_template)
823 (are_constrained_member_overloads): Remove.
824 (add_method): Call equivalently_constrained directly.
826 2014-11-03 Jason Merrill <jason@redhat.com>
828 * gcc/cp/parser.c (cp_parser_nonclass_name): Fix merge error.
830 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
832 Fixing user-reported issues and regressions
833 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
834 Only pop access checks on failed parsing.
835 * gcc/cp/pt.c (type_dependent_expr_p): Always treat a
836 requires-expr as if dependently typed. Otherwise, we try to
837 evaluate these expressions when they have dependent types.
838 * gcc/cp/constriant.cc (normalize_stmt_list): Remove unused
840 (normalize_call): Don't fold constraints during normalization.
841 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Update diagnostics.
843 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
845 Fix another introduction regression.
846 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
847 Only pop access checks on failed parsing.
849 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
851 Fix regression related to concept introductions.
852 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
853 Pop deferred access checks afer parsing the introduction.
855 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
857 Fix bug related to cleanup expressions in concept definitions.
858 * gcc/cp/constraint.cc (check_function_concept): See through
859 cleanup handlers when checking the body of a function.
860 (normalize_cast): Removed. Handled in a default case.
861 (normalize_cleanup_point): New. Normalize the expression without
864 2014-09-25 Andrew Sutton <andrew.n.sutton@gmail.com>
866 Explicitly disallow function concepts with deduced return types.
867 * gcc/cp/constraint.cc (check_function_concept): Remove check
868 for deduced return type.
869 * gcc/cp/decl.c (check_concept_fn): Explicitly check for
871 * gcc/testsuite/g++.dg/concepts/fn-concept2.C: New.
873 2014-09-24 Andrew Sutton <andrew.n.sutton@gmail.com>
875 Check requirements on function concept definitions.
876 * gcc/cp/decl.c (finish_function): Check properties of a function
878 * gcc/cp/constraint.cc (check_function_concept): New. Check
879 for deduced return type and multiple statements.
880 (normalize_misc): Don't normalize multiple statements.
881 (normalize_stmt_list): Removed.
882 * gcc/cp/cp-tree.h (check_function_concept): New.
883 * gcc/testsuite/g++.dg/concepts/fn-concept1.C: New.
885 2014-09-04 Braden Obrzut <admin@maniacsvault.net>
887 Implement concept introductions.
888 * gcc/cp/constraint.cc (deduce_concept_introduction): New.
889 (build_concept_check): Allow arg to be NULL to skip placeholder.
890 (process_introduction_parm): New.
891 (finish_concept_introduction): New.
892 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Mark introduced parm.
893 * gcc/cp/cp-tree.def: New INTRODUCED_PARM_DECL.
894 * gcc/cp/parser.c (cp_parser_declaration): Tentatively parse for
895 concept introduction.
896 (cp_parser_introduction_list): New.
897 (cp_parser_member_declaration): Tentatively parse for concept
899 (cp_parser_template_introduction): New.
900 (cp_parser_template_declaration_after_export): Parse concept
902 * gcc/cp/pt.c (convert_template_argument): Treat INTRODUCED_PARM_DECL
904 (coerce_template_parms): If INTRODUCED_PARM_DECL represents a pack then
905 match the entire parameter pack of the template.
906 (type_dependent_expression_p): Treat INTRODUCED_PARM_DECL as a
908 * gcc/testsuite/g++.dg/concepts/introduction1.C: New.
909 * gcc/testsuite/g++.dg/concepts/introduction2.C: New.
910 * gcc/testsuite/g++.dg/concepts/introduction3.C: New.
911 * gcc/testsuite/g++.dg/concepts/introduction4.C: New.
912 * gcc/testsuite/g++.dg/concepts/introduction5.C: New.
914 2014-09-01 Andrew Sutton <andrew.n.sutton@gmail.com>
916 Fixing normalization in the presence of constructor calls.
917 * gcc/cp/constraint.cc (normalize_misc): Handle constructor
919 * gcc/testsuite/g++.dg/concepts/req7.C: New.
921 2014-08-29 Andrew Sutton <andrew.n.sutton@gmail.com>
923 Fixing partial-template-id bug.
924 * gcc/cp/parser.c (cp_parser_type_name): If the returned type-decl
925 is actually a shorthand declaration, don't simulate an error.
926 * gcc/testsuite/g++.dg/concepts/template-parm10.C: New.
928 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
930 Add tests for constrained friends.
931 * gcc/testsuite/g++.dg/concepts/friend1.C: New.
932 * gcc/testsuite/g++.dg/concepts/friend2.C: New.
934 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
936 * gcc/cp/decl.c (is_concept_var): Coding style fix.
938 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
940 Fixing regression in scoping rules for templates.
941 * gcc/cp/semantics.c (fixup_tmeplate_type): Lift check to
942 finish_template_type.
943 (finish_template_type): Only do this when concepts are enabled,
944 and also when the class is actually a template. For non-dependent
945 types there are no actions to be taken.
947 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
949 Additional declaration restrictions on variable concepts.
950 * gcc/cp/decl.c (is_concept_var): New.
951 (cp_finish_decl): Check for uninitialized variable
953 (grokvardecl): Don't set the concept flag for non-template variables.
954 * g++.dg/concepts/decl-diagnose.C: Add tests.
956 2014-08-19 Ville Voutilainen <ville.voutilainen@gmail.com>
958 Ban static member function concepts.
959 * gcc/cp/decl.c (grokdeclarator): Diagnose static member function
961 * g++.dg/concepts/decl-diagnose.C: Adjust.
962 * g++.dg/concepts/mem-concept-err.C: Adjust.
963 * g++.dg/concepts/mem-concept.C: Adjust.
965 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
967 Fixes to variable concept implementation.
968 * gcc/cp/cp-tree.h (variable_concept_p): New.
969 * gcc/cp/parser.c (cp_parser_nonclass_name): Check for concepts,
971 * gcc/cp/decl.c (grokvardecl): Label concepts as concepts.
972 * gcc/cp/constraint.cc (check_call): New.
973 (normalize_call): Ensure that calls are probably to functions.
974 (normalize_template_id): Update diagnostics.
975 (finish_template_constraints): Mark assumptions as an error if
976 constraint normalization fails. This was causing normalization
977 to be run twice during the construction of a single declaration.
978 * gcc/testsuite/g++.dg/concepts: Update tests.
980 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
983 * gcc/cp/pt.c (value_dependent_expression_p): Don't assume
984 that all nodes have operands.
986 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
988 Implement normalization checks.
989 * gcc/cp/constraint.cc (normalize_expr): Delegate cast and
990 atomic nodes to a dedicated function.
991 (check_logical): Check that an && or || does not resolve to a
992 user-defined function.
993 (normalize_logical): Check operators and save the locaiton of
995 (normalize_call, normalize_var): Remove spurios error messages.
996 (normalize_cast): New, delegates to normalize atom.
997 (normalize_atom): Check that instantiated expressions can be
999 (tsubst_constraint_info): Re-normalize the associated constraints
1000 to check for post-substitution restrictions.
1001 * gcc/cp/cp-tree.h (xvalue_result_type): Add to header.
1003 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
1005 * gcc/testsuite/g++.dg/concepts: Renamed ttp* to template-parm*,
1008 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
1010 * gcc/cp/class.c (resolve_address_of_overloaded_function): Check
1012 * gcc/cp/decl.c (grokfndecl): For now, disallow constrained
1013 non-template functions.
1014 * gcc/testsuite/g++.dg/concepts: New tests.
1016 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
1018 * gcc/cp/parser.c (get_id_declarator, get_identifier): New helper
1020 (cp_check_constrained_type_parm): Don't fail on null declarators.
1021 (cp_finish_constrained_parameter): Remove redundant processing for
1022 checking declarations.
1023 (cp_maybe_type_parameter, cp_declares_type_parameter,
1024 cp_declares_type_template_parameter,
1025 cp_declares_template_template_parameter): New helper functions for
1026 determining when a parameter declaration is actually a constrained
1028 (cp_parser_default_type_template_argument,
1029 cp_parser_default_template_template_argument): Parsing support
1030 for argument types of default arguments.
1031 (cp_parser_template_parameter): Finish constrained parameters
1032 after all variadic and default arg checks.
1033 (cp_parser_parameter_declaration): Parse default arguments
1034 differently if the parameter actually declares a type parameter.
1035 * gcc/testsuite/g++.dg/concepts: New tests.
1037 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
1039 * gcc/testsuite/g++.dg/concepts/explicit-spec6.C: New test.
1041 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
1043 Fix regression in bootstrap.
1044 * gcc/cp/call.c (get_temploid): Removed. No longer called.
1045 (joust): Remove unused variable declarations.
1047 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
1049 Implement deduction-based explicit instantiation and specialization.
1050 * gcc/cp/call.c (joust): Allow all non-templates to be ordered by
1052 * gcc/cp/pt.c (get_class_bindings): Remove superfluous parameter and
1053 move constraint check into most_specialized_class.
1054 (most_constrained_function): Order functions with the same signatures
1055 by their constraints.
1056 (determine_specialization): Candidates must satisfy constraints. Also,
1057 order non-template candidates by constraints. Improve diagnostics
1058 for instances where candidates are rejected.
1059 (more_specialized_inst): New. Compare function templates.
1060 (most_specialized_instantiation): Refactor to use
1061 more_specialized_inst and order by constraints.
1062 (most_specialized_class): Candidates must satisfy constraints.
1063 * gcc/cp/decl.c (various) Cosmetic fixes.
1064 (adjust_fn_constraints): Rewrite so that class template constraints
1065 are not imposed on member function declarations.
1066 * gcc/testsuite/g++.dg/concepts: New tests.
1068 2014-08-13 Braden Obrzut <admin@maniacsvault.net>
1070 * gcc/cp/constraint.cc (deduce_constrained_parameter): Deduce concept
1071 from variable concept template-id expressions.
1072 (normalize_var): New.
1073 (normalize_template_id): Identify variable concepts.
1074 (build_concept_check): Handle variable concepts.
1075 (finish_shorthand_requirement): Handle variable concepts.
1076 (diagnose_var): New.
1077 (diagnose_node): Identify variable concepts.
1078 * gcc/cp/decl.c (grokvardecl): Pass concept flag through to
1079 check_explicit_specialization.
1080 (grokdeclarator): Allow variable concepts and pass concept flag through
1082 * gcc/cp/parser.c (cp_is_constrained_parameter): Accept variable
1084 (cp_parser_nonclass_name): Accept variable concepts.
1085 (get_concept_from_constraint): Handle variable concepts.
1086 * gcc/cp/pt.c (tsubst_copy_and_build): Lookup variable templates.
1087 (value_dependent_expression_p): Check requires expressions for value
1089 * gcc/cp/semantics.c (finish_call_expr): Don't instantiate variable
1090 templates if processing a template declaration.
1091 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Change expected error
1092 as variable concepts are now handled.
1093 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: New test.
1094 * gcc/testsuite/g++.dg/concepts/var-concepts2.C: New test.
1096 2014-08-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1098 * gcc/cp/pt.c (tsubst): Don't short circuit substitution into
1099 types when processing constraints. Also, avoid asserting when
1100 substituting into template parameters.
1101 * gcc/cp/constraint.c (tsubst_constraint_expr): Indicate that
1102 constraint processing is happening.
1103 (tsubst_constraint_info): Just substitute directly into the
1104 normalized constraints instead of re-normalizing.
1105 (diagnose_constraints): Adjust template arguments when
1106 diagnosing template constraint failures.
1107 * gcc/cp/logic.cc (decompose_assumptions): Handle null assumptions.
1109 2014-08-08 Andrew Sutton <andrew.n.sutton@gmail.com>
1111 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Don't re-normalize
1112 constraints, it's already been done.
1113 * gcc/cp/cp-tree.h (*_requirement[s]): Renamed to *_constraint[s] to
1114 reflect wording in specification. Removed reduce_requirements.
1115 * gcc/cp/pt.c (process_template_parm, tsubst_pack_conjunction): Update
1117 (fn_type_unification): Remove constraint check.
1118 * gcc/cp/parser.c (cp_parser_type_parameter,
1119 cp_parser_trailing_requirements,
1120 cp_parser_template_declaration_after_export,
1121 synthesize_implicit_template_parm): Update from renaming.
1122 * gcc/cp/constraint.cc: Renamed a lot of functions to reflect wording
1124 (finish_template_constraints): Normalize associated constraints.
1125 (tsubst_constraint_expr): Renamed from instantiate_requirements.
1126 Normalize associated constraints.
1127 (check_satisfied): Return true if the arguments refer to template
1129 (all_constraints_satisfied, any_conjunctions_satisfied,
1130 check_requirements): No longer needed.
1131 (check_diagnostic_constraints): Just normalize the expression, don't
1134 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
1136 * gcc/testsuite/g++.dg/concepts/concepts.exp: Add missing argument
1139 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
1141 * gcc/cp/constraints.c (tsubst_requires_body, instantiate_requirements):
1142 Lift the unevaluated operand guard to the entire constraint expression.
1143 (check_satisfied, all_constraints_satisfied,
1144 any_conjunctions_satisfied): Rewrite constraint checking to use
1145 atomic constraints. Prevents instantiation of concepts.
1146 (check_diagnostic_constraints): Recursively decompose and check
1147 constraints for fine-grain diagnostics.
1148 (diagnose_*): Use new constraint checking function.
1151 2014-07-30 Braden Obrzut <admin@maniacsvault.net>
1153 * gcc/cp/parser.c (cp_parser_trailing_requirements): Handle requires
1154 keyword manually so that we can push function parameters back into
1156 * gcc/cp/decl.c (push_function_parms): New. Recovers and reopens
1157 function parameter scope from declarator.
1158 * gcc/testsuite/g++.dg/concepts/req*.C: New tests.
1160 2014-07-30 Andrew Sutton <andrew.n.sutton@gmail.com>
1162 * gcc/testsuite/g++.dg/concepts/test.C: Removed.
1164 2014-07-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1166 * gcc/cp/cp-tree.h (more_constraints): Remove
1167 (subsumes_constraints): Renamed from more_constraints
1168 (more_constrained): Repurposed
1169 * gcc/cp/call-c (template_decl_for_candidates): Rename to get_temploid,
1170 only get template info for member functions of a class template
1172 (joust): Handle member functions of class template specializations
1173 separately from function templates. This matches the new wording in
1175 * gcc/cp/logic.cc (match_terms): Make inline.
1176 (subsumes_constraints): Rename to subsumes_constraints_nonnull.
1177 * gcc/cp/pt.c (is_compatible_template_arg): Use subsumes.
1178 (more_specialized_fn): Use usubsumes_constraints.
1179 (more_specialized_class): Use more_constrained.
1180 * gcc/cp/constraint.cc (more_constraints): Removed.
1181 (more_constrained): New.
1183 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1185 * gcc/cp/typeck.c (cp_build_function_call_vec): Emit diagnostic
1186 at the input location.
1187 * gcc/cp/error.c (dump_template_decl): Constraints are never invalid
1188 in this way. Also fixes brace warning.
1190 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1192 * gcc/cp/tree.c (cp_tree_equal): compare constraint infos by
1193 their associated constraints (patch by Braden Obrzut).
1194 * gcc/cp/logic.c (decompose_assumptions): Don't decompose errors.
1195 (subsumes_constraints): Update to use new macros.
1196 * gcc/cp/cp-tree.h (tree_constraint_info): Rewrite constraints
1197 to cache leading, trailing, and associated requirements.
1198 (CI_SPELLING, CI_REQUIREMENTS): Remove
1199 (CL_LEADING_REQS, CI_TRAILING_REQS, CI_ASSOCIATED_REQS): New
1200 accessors for constraint info field.
1201 (save_leading_requirements, save_trailing_requirements,
1202 valid_template_requirements_p): New.
1203 (make_constraints): Removed.
1204 (instantiate_requirements): Add flag to substitute in either
1205 dependent/non-dependent mode.
1206 (tsubst_constraint_info): New.
1207 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_clause): New.
1208 * gcc/cp/cxx-pretty-print.c (pp_cxx_init_declarator): Remove.
1209 (pp_cxx_function_definition): Print trailing constraints if they
1211 (pp_cxx_init_declarator): New. Print trailing requirements.
1212 (pp_cxx_template_declaration): Print leading requirements.
1213 (pp_cxx_requires_clause): New.
1214 * gcc/cp/pt.c (build_template_decl): Ensure completion of constraints
1215 when associating them with the template.
1216 (add_inherited_template_parms): Update to new constraint mechanisms.
1217 (redeclare_class_template): Update to new constraint mechanisms.
1218 (tsubst_decl): Update to new constraint mechanism.
1219 * gcc/cp/parser.c (cp_parser_lambda_expression): Save off constraints
1220 in a generic lambda.
1221 (cp_check_constrained_type_parm): Save leading requirements instead
1223 (cp_parser_trailing_requirements): Simplify by just saving the trailing
1225 (cp_parser_init_declarator): Save off constraints before parsing the
1227 (cp_parser_member_declaration): Save off requirements before parsing
1229 (cp_parser_requires_clause): Defer constexpr check until as late as
1231 (cp_parser_template_declaration_after_export): Save leading requirements
1232 instead of finishing them.
1233 (synthesize_implicit_template_parm): Save leading requirements when
1234 processing a constrained-type-specifier.
1235 * gcc/cp/class.c (get_member_fn_template): Update to use new constraint
1237 * gcc/cp/call.c (constraint_failure): Renamed from
1238 template_constraint_failure. Produce reasons for non-template functions.
1239 (is_constrainable_non_template_fn): Removed.
1240 (add_function_candidate): Use new constraint association framework.
1241 * gcc/cp/ptree.c (cxx_print_xnode): Dump leading, trailing requirements.
1242 * gcc/cp/error.c (dumpl_template_decl): Print a leading requires-clause.
1243 (dump_function_decl): Print a trailing requires-clause.
1244 * gcc/cp/semantics.c (finish_template_template_parm): Finish
1245 template constraints before associating them.
1246 * gcc/cp/constraint.cc (reduce_call): Don't fold constants when
1248 (reduce_template_id): Replace EXPR_LOCATION in diagnostics. Return
1249 error_mark_node instead of corrected call expression.
1250 (reduce_requirements): Don't normalize a null expression.
1251 (make_constraints): Removed.
1252 (get_constraints): Updated.
1253 (set_constraint): Updated.
1254 (get_shorthand_requirements): Use the appropriate macro.
1255 (build_constraint_info, init_leading_requirements,
1256 init_trailing_requirements, update_leadng_requirements,
1257 update_trailing_requirements, save_leading_requirements,
1258 save_trailing_requirements): New.
1259 (finish_template_requirements): Analyze and decompose constraints.
1260 (valid_template_requirements_p): New.
1261 (instantiate_requirements): New flag.
1262 (tsubst_constraint_info): New.
1263 (check_requirements): Update.
1264 (check_constraints): Add another round of instantiation to ensure
1265 that all non-constexpr exprs are folded out of the expression.
1266 (check_constraints): Update.
1267 (equivalent_constraints): Redefine constraint equivalence in terms
1268 of tokens (patch by Braden Obrzut).
1269 (diagnose_trait, diagnose_check, diagnose_requires,
1270 diagnose_constraints): Update.
1271 * gcc/cp/decl2.c (check_classfn): Update constraint mechanisms.
1272 * gcc/cp/decl.c (decls_match): Update to use new constraints.
1273 (duplicate_decls): members match if they have equivalent constraints.
1274 (get_leading_template_requirements): New.
1275 (adjust_out_of_class_fn_requirements): New.
1276 (grokfndecl): Associate requirements with a function declaration.
1277 * gcc/testsuite/g++.dg/concepts/*: New tests.
1279 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1281 * gcc/c-family/c.opt (flag_concepts): Don't enable by default.
1282 * gcc/c-family/c-opts.c (set_std_cxx1z): Enable concepts if
1283 -std=cxx1z is selected.
1284 * gcc/c-family/c-format.c (gcc_cxxdia): Add "Z" as format specifier.
1285 * gcc/cp/c-common.c (cxx_dialect): Make -std=c++98 the default
1287 * gcc/cp/lex.c (cxx_init): Don't set flag_concepts explicitly.
1288 * gcc/testsuite/g++.dg/concepts/*.C: Update build flags.
1290 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1292 * gcc/cp/cp-tree.h (DECL_CONSTRAINTS): Remove this macro; use
1293 get_constraints instead.
1294 (set_constraints): new.
1295 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Use
1297 * gcc/cp/pt.c (get_specialization_constraints): Use get_constraints.
1298 (build_template_decl): Use get_constraints.
1299 (process_partial_specialization): Use get_constraints.
1300 (add_inherited_template_parms): Use get_constraints.
1301 (redeclare_class_template): Use get_constraints.
1302 (is_compatible_template_arg): Use get_constraints.
1303 (tsubst_friend_class): Use get_constraints.
1304 (tsubst_decl): Uset get_constraints.
1305 * gcc/cp/semantics.c (finish_template_template_parm): Use
1307 (fixup_template_type): Use get_constraints.
1308 * gcc/cp/constraint.cc (constraints): New global association
1309 of declarations to constraints.
1310 (get_constraints): Return the associated constraints from the
1312 (set_constraints): New. Associate constraints with a declaration.
1313 (check_template_constraints): Use get_constraints.
1314 (equivalently_constrained): Use get_constraints.
1315 (more_constrained): Use get_constraints.
1316 (diagnose_constraints): Use get_constraints.
1317 * gcc/testsuite/g++.dg/concepts/partial-spec.C: New.
1319 2014-06-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1321 * gcc/cp/parser.c (cp_parser_requires_clause): Don't fold expressions
1322 when parsing a requires-clause.
1323 * gcc/cp/constraint.cc (reduce_requirements): Don't fold
1324 expressions during constraint normalization.
1326 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1328 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): Defer
1329 handling the BASELINK check until concept-resolution in order to
1330 allow member conceps.
1331 (cp_parser_nonclass_name): Also Check for concept-names when the
1332 lookup finds a BASELINk.
1333 * gcc/cp/constraint.cc: (resolve_constraint_check) If the call
1334 target is a base-link, resolve against its overload set.
1335 (build_concept_check): Update comments and variable names to
1336 reflect actual processing.
1337 * gcc/testuite/g++.dg/concepts/mem-concept.C: New test.
1338 * gcc/testuite/g++.dg/concepts/mem-concept-err.C: New test.
1340 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1342 * gcc/cp/error.c (dump_expr): Pretty print placeholder to improve
1345 2014-06-17 Braden Obrzut <admin@maniacsvault.net>
1347 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): If getting
1348 a baselink, use the referred-to function/overload declarations rather
1351 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
1353 * gcc/cp/constraint.cc (deduce_constrained_parameter): Refactor
1354 common deduction framework into separate function.
1355 (build_call_check): New.
1356 (build_concept_check): Take additional arguments to support the
1357 creation of constrained-type-specifiers from partial-concept-ids.
1358 (build_constrained_parameter): Take arguments from a partial-concept-id.
1359 * gcc/cp/cp-tree.h (build_concept_check, biuld_constrained_parameter):
1360 Take a template argument list, defaulting to NULL_TREE.
1361 * gcc/cp/parser.c (cp_parser_template_id): Check to see if a
1362 template-id is a concept check.
1363 (cp_check_type_concept): Reorder arguments
1364 (cp_parser_allows_constrained_type_specifier): New. Check contexts
1365 where a constrained-type-specifier is allowed.
1366 (cp_maybe_constrained_type_specifier): New. Refactored common rules
1367 for concept name checks.
1368 (cp_maybe_partial_concept_id): New. Check for
1369 constrained-type-specifiers.
1370 * gcc/testuite/g++.dg/concepts/partial.C: New tests.
1371 * gcc/testuite/g++.dg/concepts/partial-err.C: New tests.
1372 * gcc/testuite/g++.dg/concepts/concepts.exp: Add missing test driver.
1374 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
1376 * gcc/cp/parser.c (cp_check_type_concept): New.
1377 (cp_check_concept_name): Remove redundant condition from check.
1378 Diagnose misuse of non-type concepts in constrained type specifiers.
1379 * gcc/testuite/g++.dg/concepts/generic-fn.C: Add tests for
1380 non-simple constrained-type-specifiers and nested-name-specifiers
1382 * gcc/testuite/g++.dg/concepts/generic-fn-err.C: New tests for
1383 diagnosing ill-formed programs.
1385 2014-06-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1387 * gcc/cp/cp-tree.h (build_constrained_parameter): Renamed fro
1388 describe_tempalte_parm.
1389 * gcc/cp/parser.c (cp_check_constrained_type_parm): New. Prevent
1390 declaration of cv-qualifed or non-id types.
1391 (cp_constrained_type_template_parm): Renamed, check for invalid
1393 (cp_constrained_template_template_parm): Renamed, check for invalid
1395 (cp_constrained_non_type_tmeplate_parm): Renamed.
1396 (cp_finish_constrained-parameter): Support checking of decarlarations.
1397 (cp_check_concept_name): Renamed. Add initial support for auto
1398 and constrained-type-specifiers in compound requirements.
1399 (cp_parser_nonclass_name): Only check for concept names if -fconcepts
1401 (cp_manage_requirements): New RAII guard for managinging the
1402 current_template_reqs variable during declaration parsing.
1403 (cp_paresr_trailing_requirements): Refactored common parsing
1404 requirements from cp_parser_init_declarator and
1405 cp_parser_member_declarator. Take terse constraints from implicit
1406 parameter declarations.
1407 (cp_parser_init_declarator): Cleanup, refactor requirement logic.
1408 (cp_parser_type_id_1): Allow auto in compound requirements.
1409 (cp_parser_member_declaration): Cleanup, refactor requirement logic.
1410 (cp_parser_compound_requirement): Note parsing state for the
1411 trailing-type-id so we can get auto and constrained-type-specifiers.
1412 (cp_parser_function_definition_after_decl): Remove broken constraint
1414 * gcc/cp/parser.h (cp_parser): New member.
1415 * gcc/cp/constraint.cc (finish_validtype_expr): Initial (non-)handling
1416 of auto in type requirements.
1417 (finish_concept_name): Moved to cp_check_concept_name.
1418 * gcc/testuite/g++.dg/concepts/constrained-parm.C: New test.
1419 * gcc/testuite/g++.dg/concepts/generic-fn.C: New test.
1422 2014-03-10 Andrew Sutton <andrew.n.sutton@gmail.com>
1424 * gcc/testuite/g++.dg/concepts/fn1.C: New test.
1425 * gcc/testuite/g++.dg/concepts/fn2.C: New test.
1427 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1429 * gcc/cp/parser.c (synthesize_implicit_template_parm): Allow concepts
1430 to declare implicit template parameters. Only synthesize new parameters
1431 if the concept name is new.
1432 (finish_concept_name): Moving into parser.c for the time being. Needs
1433 to be rewritten to remove duplicate code between parser.c and
1436 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1438 * gcc/cp/pt.c (tsubst_copy): Expand pack expansions as conjunctions.
1440 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1442 * gcc/cp/pt.c (tsubst_pack_conjunction): Don't try to conjoin
1443 dependent expressions.
1445 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1447 * gcc/cp/semantics.c (fixup_template_type): Compare primary template
1448 types to specializations using structural types so we don't run into
1449 canonical type errors with constrained specializations.
1451 2013-11-08 Andrew Sutton <andrew.n.sutton@gmail.com>
1453 * gcc/cp/pt.c (add_inherited_template_parms): Instantiate requirements
1454 in a processing template decl context.
1456 2013-11-05 Andrew Sutton <andrew.n.sutton@gmail.com>
1458 * gcc/cp/semantics.c (fixup_template_type): Add a same-type check
1459 for specialiations so we don't accidentally match non-dependent
1460 specializations having a different type.
1462 2013-10-26 Ville Voutilainen <ville.voutilainen@gmail.com>
1464 * gcc/cp/decl.c (grokdeclarator): Reject concept keyword
1465 in typedefs, function parameters, data members, non-static
1466 member functions and variables. Allow static member functions
1469 2013-10-30 Andrew Sutton <andrew.n.sutton@gmail.com>
1471 * gcc/cp/semantics.c (fixup_template_type): Don't emit errors when
1472 no templates can be found with matching constraints.
1474 2013-10-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1476 * gcc/cp/parsre.c (cp_parser_requires_expression): Gracefully
1477 fail when parsing a requires expr outside a template.
1479 2013-10-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1481 * gcc/cp/c-common.c (c_common_r): Remove unused keywords "assume",
1482 "axiom", and "forall".
1483 * gcc/cp/c-common.h (rid): Removed unused reserved word ids.
1485 2013-10-24 Edward Smith-Rowland <3dw4rd@verizon.net>
1487 * gcc/cp/typeck.c (cp_build_function_call_vec): Use unused variable
1490 2013-10-23 Andrew Sutton <andrew.n.sutton@gmail.com>
1492 * gcc/cp/class.c (get_member_fntemplate): New.
1493 (are_constrained_member_overloads): Only get a template declaration
1494 if the member function is, in fact, a template or temploid.
1495 * gcc/cp/pt.c (check_explicit_specialization): Do not allow
1496 explicit specializations to be declared 'concept', and do not allow
1497 an explicit specialization of a concept.
1498 * gcc/cp/decl.c (grokfndecl): Propagate the concept flag to
1499 check_explicit_specialization.
1501 2013-10-22 Andrew Sutton <andrew.n.sutton@gmail.com>
1503 * gcc/c-family/c-common.c (cxx_dialect): Make the default
1505 * gcc/cp/constraint.cc (check_constrained_friend): Don't assert
1508 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1510 * gcc/cp/logic.cc (left_requires), (decompose_left): Add
1511 decomposition rules for requires expressions.
1512 (subsumes_requires), (subsumes_prop): Add subsumption rules for
1513 requires expressions.
1514 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failed conversion
1517 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1519 * gcc/cp/constraint.cc (finish_concept_name): Allow functions with
1520 the same name as concepts to resolve as call expressions in the
1523 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1525 * gcc/cp/constraint.cc (conjoin_requiremens): New.
1526 (resolve_constraint_check): Filter non-concept candidates before
1527 coercing arguments. Perform deduction in a template-decl processing
1528 context to prevent errors during diagnosis.
1529 (finish_concept_name), (finish_shorthand_requirement),
1530 (get_shorthand_requirements): New.
1531 * gcc/cp/pt.c (template_parm_to_arg): Make non-static.
1532 (process_templat_parm): Build shorthand requirements from the
1533 parameter description.
1534 (end_templat_parm_list): New.
1535 (convert_placeholder_argument): New.
1536 (convert_template_argument): Match placeholder arguments against
1537 any template parameter.
1538 (tsubst_pack_conjuction): New.
1539 (tsubst_expr): Expand a pack as a conjunction.
1540 (type_dependent_expression_p): Placeholders are always type
1542 * gcc/cp/parser.c (cp_is_constrained_parameter),
1543 (cp_finish_template_type_parm), (cp_finish_template_template_parm)
1544 (cp_finish_non_type_template_parm), (cp_finish_constrined_parameter):
1546 (cp_parser_template_parameter): Handle constrained parameters.
1547 (cp_parser_nonclass_name): An identifier naming an overload set
1548 may declare a constrained parameter.
1549 (cp_parser_type_parameter), (cp_parser_template_declaration_after_exp):
1550 Get shorthand requirements from the tmeplate parameter list.
1551 * gcc/cp/cp-tree.h (TEMPLATE_PARM_CONSTRAINTS): New.
1553 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1555 * gcc/cp/cp-tree.h (check_constrained_friend): Take requirements as
1557 * gcc/cp/constraints.cc (check_constrained_friend): Do not diagnose
1558 errors in unconstrained friend declarations.
1559 * gcc/cp/parser.cc (cp_parser_member_declaration): Pass current
1560 requirements to check_constrained_friend.
1562 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1564 * gcc/cp/parser.c (cp_parser_member_declaration): Check that
1565 a constrained friend definition is valid.
1566 * gcc/cp/decl.c (grokfndecl): Disallow constrained friend template
1568 * gcc/cp/constraints.cc (check_constrained_friend): New.
1569 * gcc/cp/typeck.c (cp_build_function_call_vec): Diagnose constraints
1570 in the presence of the failure of a single candidate.
1571 * gcc/cp/cp-tree.h (check_constrained_friend): New.
1572 * gcc/cp/call.c (is_non_template_member_fn): Make inline.
1573 (is_non_template_friend), (is_constrainable_non_template_fn): New.
1574 (add_function_candidate): Predicate check on
1575 is_constrainable_non_template_fn.
1577 2013-09-10 Andrew Sutton <andrew.n.sutton@gmail.com>
1579 * gcc/cp/cp-tree.h (TEMPLATE_PARMS_CONSTRAINTS): New.
1580 * gcc/cp/parser.c (cp_parser_template_declaration_after_export),
1581 (cp_parser_type_parameter): Use TEMPLATE_PARMS_CONSTRAINTS.
1582 * gcc/cp/semantics.c (fixup_template_scope): Use
1583 TEMPLATE_PARMS_CONSTRAINTS.
1585 2013-09-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1587 * gcc/cp/cxx-pretty-print.c (pp_cxx_compound_requirement),
1588 (pp_cxx_type_requirement), (pp_cxx_validtype_expr): Use
1589 pp->type_id() instead of pp_cxx_type_id().
1591 2013-09-09 Andrew Sutton <andrew.n.sutton@gmail.com>
1593 * gcc/cp/pt.c (get_class_bindings): Pass the partial specialization
1594 for constraint evaluation. Evaluate constraints, resulting in
1595 deduction failure on error.
1596 (get_specializaing_template_decl), (get_specialization_constraints),
1597 (maybe_new_partial_specialization): New.
1598 (maybe_process_partial_specialization): Allow the creation of
1599 new types for constrained partial specializations.
1600 (process_partial_specialization): Modify the canonical type
1601 of constrained partial specializations.
1602 (instantiate_class_template_1): Do not explicitly check constraints
1603 during class template instantiation.
1604 (tsubst_decl): Instantiate the constraints of template declarations.
1605 (more_specialized_class): Pass specializations to get_class_bindings().
1606 Compare specialization constraints if the types are equivalent.
1607 (most_specialized_class): Pass specialization to get_class_bndings().
1608 * gcc/cp/decl2.c (check_class_fn): Get the decl's requirements from
1609 either the current template reqs or from the template parameters.
1610 Allow overloading of constrained out-of-class member definitions.
1611 * gcc/cp/semantics.c (fixup_template_type): New. Match the template
1612 scope to a specialization with appropriate constraints.
1613 (finish_template_type): Fix template type when entering scope.
1614 * gcc/cp/parser.c (cp_parser_parse_type_parameter): Attach
1615 requirements to the current template parameter list.
1616 (cp_parser_init_declarator): Parse requires clauses for out-of-class
1617 member definitions. Be sure to restore current constraints before
1618 exiting the function.
1619 (cp_parser_member_declarator): Restore the previous requirements in
1620 an early-exit branch.
1621 (cp_parser_late_parsing_for_member): Restore constraints after
1622 maybe_end_member_template_processing().
1623 (cp_parser_template_declaration_after_exp): Attach constraints to
1624 the current template parameters.
1625 * gcc/cp/constraint.cc (reduce_template_id): Don't crash when
1626 omitting ()'s on constraint calls.
1627 (check_requirements): Don't evaluate dependent arguments.
1628 (check_constraints): Don't try to evaluate when arguments are
1630 (equivalent_constraints): Optimize the case when a and b are the
1633 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1635 * gcc/cp/semantics.c (trait_expr_value): Evaluate __is_same_as.
1636 (finish_trait_expr): Check __is_same_as and __is_convertible_to.
1637 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failures in
1639 * gcc/cp/parser.c (cp_parser_primary_expression),
1640 (cp_parser_trait_expr): Parse __is_same_as.
1641 * gcc/cp/cp-tree.h (cp_trait_kind): Add CPTK_IS_SAME_AS.
1642 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Pretty print
1645 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1647 * gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
1648 requires expr parameter list.
1650 2013-07-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1652 * gcc/cp/parser.c (cp_parser_requires_expr): Update parser using new
1653 requires expression nodes. Renamed some grammar productions to better
1654 reflect the representation of the syntax. Create a new scope for
1655 requires parameters.
1656 (cp_parser_nested_requirement): Wrap results in a NESTED_REQ node.
1657 * gcc/cp/semantics.c (xvalue_result_type): New.
1658 (trait_expr_value): Evaluate __is_convertible_to.
1659 (finish_requires_expr): Implemented, along with other functions to
1660 construct and evaluate nodes for template constraints.
1661 (potential_constant_expression_1): Handle requires expressions.
1662 (finish_template_requirements), (finish_requires_expr), etc:
1663 Move to constraint.cc.
1664 * gcc/cp/cp-tree.def: (REQUIRES_EXPR), (EXPR_REQ), (TYPE_REQ),
1665 (NESTED_REQ), (VALIDEXPR_EXPR), (VALIDTYPE_EXPR), (CONSTEXPR_EXPR):
1667 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Make new nodes typed.
1668 * gcc/cp/cp-tree.h (finish_expr_requirement),
1669 (finish_type_requirement), (finish_nested_requirement),
1670 (finish_validexpr_expr), (finish_validtype_expr),
1671 (finish_constexpr_expr): New.
1672 * gcc/cp/pt.c (convert_nontype_argument): Use can_convert_standard.
1673 (retrieve_local_specialization), (register_local_specialization),
1674 (extract_fnparm_pack): Make non-static.
1675 (tsubst_expr): Substitution rules for requires expressions.
1676 (instantiate_requirements): Move to constraints.cc
1677 (tsubst_constraint): Remove.
1678 * gcc/cp/call.c (can_convert): Allow user-defined conversions.
1679 (can_convert_standard): New.
1680 * gcc/cp/cvt.c (convert_to_reference): Use can_convert_standard.
1681 * gcc/cp/search.c (check_final_overrider): Use can_cnvert_standard.
1682 * gcc/cp/typeck.c (build_static_cast_1): Use can_convert_standard.
1683 * gcc/cp/error.c (dump_expr): Pretty print new nodes.
1684 * gcc/cp/cxx-pretty-print.c (pp_cxx_primary_expression): Pretty
1685 print new expr/req nodes.
1686 (pp_cxx_requires_expr): New along with related functions for
1687 pretty printing requirements.
1688 (pp_cxx_parameter_declaration_clause): Accommodate "raw" parameter
1689 lists in addition to function decls.
1690 (pp_cxx_requirement_parameter_list): Unified with parameter decl clause.
1691 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_expr): New along with
1692 related functions for pretty printing requirements.
1693 * gcc/cp/logic.cc: Move header comments to top of file.
1694 * gcc/cp/constraint.cc (reduce_requirements): Handle requires
1696 (diagnose_constraints): Rename and handle requires expressions.
1698 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1700 * gcc/cp/error.c (cp_printer): Fix unnecessary whitespace change.
1701 * gcc/cp/constraint.cc (diagnose_node): Don't fail diagnosing
1704 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1706 * gcc/cp/class.c (are_constrained_member_overloads): Fix doc typos.
1708 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1710 * gcc/cp/parser.c (cp_parser_init_declarator): Parse template
1711 requirements for out-of-class member definitions.
1712 * gcc/cp/decl2.c (check_classfn): Include match out-of-class
1713 definitions using constraints.
1714 * gcc/cp/constraint.cc (equivalently_constrained). Use get_constraints.
1715 (more_constrained). Use get_constraints.
1717 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1719 * gcc/cp/cp-tree.h (tree_template_info). Remove constraint from
1721 (check_template_info): Removed (unused).
1722 (TI_CONSTRAINT): Removed (no longer needed) along with related macros.
1723 (DECL_CONSTRAINTS): New. Get constraints from DECL_SIZE_UNIT for
1725 (build_template_info): Removed overload taking constraints.
1726 (get_constraints): Removed (no longer needed).
1727 * gcc/cp/class.c (are_constrained_member_overlaods): Allow constrained
1728 member function templates to be differentiated as overloads.
1729 * gcc/cp/decl.c (decls_match): Only compare constraints on
1731 (grokfndecl): Don't pass constraints to build_template_info.
1732 * gcc/cp/tree.c (bind_template_template_parm): Don't pass constraints
1733 to build_template_info.
1734 * gcc/cp/pt.c (build_template_info): Removed overload taking
1736 (check_explicit_specialization): Don't build new constraints for
1738 (build_template_decl): Pass constraints. Update docs.
1739 (process_partial_specialization): Stub out support for constrained
1740 partial specialiations.
1741 (push_template_decl_real): Build template decls with current template
1742 reqs. Don't pass constraints to build_template_info.
1743 (add_inherited_template_parms): Build new constraints from inherited
1744 template constructors.
1745 (redeclare_class_template): Update to new constraint interface.
1746 (is_compatible_template_arg): Update to new constraint interface.
1747 (lookup_template_class_1): Don't build new constraints or pass them to
1748 build_template_info.
1749 (instantiate_class_template_1): Update to new constraints interface.
1750 (tsubst_decl): Don't build new constraints or pass them to
1751 build_template_info. For function templates, explicitly instantiate
1752 new constraints for member functions of class templates.
1753 * gcc/cp/semantics.c: Associate constraints with template template
1754 parms directly, not through template info.
1755 * gcc/cp/constraint.cc (get_constraints): Simplified to use new constraints
1757 (check_constraints): Update to use new constraints interface.
1758 (equivalently_constrained): Update to use new constraints interface.
1759 (more_constrained): Update to use new constraints interface.
1760 * gcc/cp/parser.cpp (cp_parser_late_parsing_for_member): Update to use
1761 new constraints interface.
1762 * gcc/cp/call.c (is_non_template_member_fn): New.
1763 (add_function_candidate): Only check constraints for non-template member
1766 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1768 * gcc/cp/parser.c (cp_parser_requires_clause): Pulled out of
1769 cp_parser_requires_clause_opt for reuse in the requires expr parser.
1770 (cp_parser_requires_expression): New, along with a family of
1771 sub-expression parsers for the new feature.
1772 * gcc/cp/semantics.c (finish_requires_expr): Stub.
1773 (finish_syntax_requirement): Stub.
1774 (finish_type_requirement): Stub.
1775 (finish_constexpr_requirement): Stub.
1776 (finish_noexcept_requirement): Stub.
1777 (finish_requires_expr): Stub.
1778 * gcc/cp/cp-tree.h: (finish_requires_expr): New.
1779 (finish_syntax_requirement): New.
1780 (finsih_type_requirement): New.
1781 (finish_constexpr_requirement): New.
1782 (finish_noexcept_requirement): New.
1784 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1786 * gcc/cp/error.c (subst_to_string): Allow this to be called explicitly
1787 passing template parameters in the TREE_TYPE and with a null
1789 * constraint.cc (check_requirements): New overload taking template
1791 (check_constraints.cc): Move instantiation and checking into the
1792 new check_requirements overload.
1793 (diagnose_requirements): New family of functions for diagnosing
1794 constraint failures.
1796 2013-06-18 Andrew Sutton <andrew.n.sutton@gmail.com>
1798 * gcc/cp/class.c (are_constrained_member_overloads): New.
1799 (add_method): Allow overloading of constrained member functions.
1800 * gcc/cp/call.c (rejection_reason_code): New rr_constraint_failure.
1801 (template_constraint_failure): New.
1802 (add_function_candidate): Check for viability as a precondition to use.
1803 (add_template_candidate_real): Integrate constraint diagnostics.
1804 Provide constraint info for new template instantiations.
1805 (print_z_candidate): Emit diagnostics for constraint failures.
1806 (template_decl_for_candidate): New.
1807 (joust): Allow non-member templates of class templates to be evaluated
1808 in more_specialized_fn if they are constrained.
1809 * gcc/cp/ptree.c (cxx_print_xnode): Dump constraint info.
1810 * gcc/cp/semantics.c (finish_template_template_parm): Build template
1811 info for template template parameters.
1812 (is_unary_trait): New.
1813 (is_binary_trait): New.
1814 (finish_trait_expr): Check for binary traits using new function.
1815 * gcc/cp/constraint.cc (join_requirements): New
1816 (conjoin_requirements): Join expressions correctly. Fixed docs.
1817 (disjoin_requirements): Removed.
1818 (is_constriant): Removed.
1819 (resolve_constraint_check): New. Replaces previous get_constraint
1820 check and related functions.
1821 (get_constraints): New, along with helper functions.
1822 (suppress_template_processing): New.
1823 (check_template_constraints): New, along with helper functions.
1824 (equivalent_constraints): New.
1825 (equivalently_constrained): New.
1826 (more_constraints): New.
1827 (more_constrianed): New.
1828 (diagnose_constraint_failure): New.
1829 * gcc/cp/decl.c (decls_match): Check for constraint equivalence if
1830 the types are the same.
1831 (check_concept_refinement): New.
1832 (are_constrained_overloads): New.
1833 (duplicate_decls): Handle constraints for ambigous declarations. Check
1834 and diagnose concept refinement.
1835 (check_concept_fn): Don't fail completely just because the concept
1836 isn't defined correctly. Allow analysis to continue as if declared
1837 constexpr. Concepts must return bool.
1838 * gcc/cp/tree.c (bind_template_template_parm): Provide empty
1839 constraints for bound template template parameters.
1840 * gcc/cp/logic.cc: Rewrite of proof state and related structures and
1841 decomposition logic. Removed right-decomposition logic, but retained
1842 right-logical rules.
1843 (match_terms): Renamed from entails.
1844 (subsumes_prop): Cleanup, added specific handlers for and/or cases.
1845 (subsumes_constraints): Update from interface change.
1846 * gcc/cp/cp-tree.h (check_constraint_info): Renamed and applied
1848 (check_template_info): Renamed and applied interface change.
1849 (cp_unevaluated): New
1850 (local_specialization_stack): New.
1851 (coerce_template_parms): New.
1852 (is_unary_trait): New.
1853 (is_binary_trait): New.
1854 (get_constraints): New.
1855 (check_constraints): New.
1856 (check_template_constraints): New.
1857 (subst_template_constraints): New.
1858 (equivalent_constraints): New.
1859 (equivalently_constrained): New.
1860 (more_constraints): New.
1861 (more_constrained): New.
1862 (diagnose_constraints_failure): New.
1863 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Print the
1864 template requirements.
1865 * gcc/cp/pt.c (local_specialization_stack): New.
1866 (build_template_info): Refactor into 3-argument version and
1867 incorporate template requirements.
1868 (check_explicit_specialization): Instantiate requirements for
1870 (push_template_decl_real): Include constraints in template info.
1871 (redeclare_class_template): Diagnose redeclaration with different
1873 (is_compatible_template_arg): New.
1874 (convert_template_argument): Check constraints on template template
1875 arguments and diagnose errors.
1876 (lookup_template_class_1): Check constraints on alias templates.
1877 Keep constraints with instantiated types.
1878 (instantiate_class_template_1): Check constraints on class templates.
1879 (tsubst_decl): Instantiate and keep constraints with template info.
1880 Also, allow dependent pack arguments to produce neww parameter
1881 packs when instantiated.
1882 (coerce_template_parms): New overload.
1883 (tsubst_copy): Handle REAL_TYPE and BOOLEAN_TYPE.
1884 (tsubst_copy_and_build): PARM_DECLs can be instantiated as pack
1885 expansions (used with requires expression).
1886 (fn_type_unification): Check constraints for function templates.
1887 (more_specialized_fn): Determine which candidate is more constrained.
1888 (substitute_template_parameters): Removed.
1889 (tsubst_constraint): New.
1890 (substitute_requirements): New.
1891 * gcc/cp/parser.c: (cp_parser_optional) Removed along with helper
1893 (cp_unevaluated): New.
1894 (cp_parser_type_parameter): Check for requires kw explicitly, and
1895 save/clear template requirements before parsing the requires clause.
1896 (cp_parser_requires_clause): Removed.
1897 (cp_parser_template_declaration_after_exp): Check for requires kw
1899 * gcc/system.h (cstdlib): Removed include.
1900 * gcc/c-family/c-common.h (D_CXX_CONCEPTS): New flag for disabling
1902 * gcc/c-family/c.opt (flag_concepts): Remove redundant declaration.
1903 * gcc/c-family/c-common.c (c_common_r): Concept-specific keywords
1904 are only enabled when concepts are enabled.
1906 2013-06-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1908 * gcc/system.h (cstdlib): Include <cstdlib> to avoid poisoned
1910 * gcc/c-family/common.c (c_common_r): Added __is_same_as intrinsic,
1911 removed previous, unused intrinsics.
1912 * gcc/c-family/common.h (rid): Added RID_IS_SAME_AS.
1913 * gcc/cp/parser.c (take): New.
1914 (cp_requires_clause): New.
1915 (cp_requires_clause_opt): New.
1917 (cp_parser_optional_if_token): New.
1918 (cp_parser_optional_if_not_token): New.
1919 (cp_parser_optional_if_keyword): New.
1920 (cp_parser_decl_specifier_seq): Parse 'concept' as a declspec.
1921 (cp_parser_type_parameter): Parse constrained template template parms.
1922 (cp_parser_member_specification_opt): Parse member constraints after
1923 the declaration, not before.
1924 (cp_parser_template_declaration_after_exp): Rewrote parsing for
1925 template requirements
1926 (cp_parser_late_parsing_for_member): Re-push the current template
1927 requirements when late-parsing member definitions.
1928 * gcc/cp/decl.c (check_concept_fn): New.
1929 (grokfndecl): Semantics for concept declspec.
1930 (grokdeclarator): Semantics for concept declspec.
1931 (xref_tag_1): Update to new interface.
1932 * gcc/cp/constraint.cc (make_constraints): New.
1933 * gcc/cp/cp-objcp-common.c (cp_tree_size): Add case for constraint_info.
1934 * gcc/cp/cp-tree.h (require): New.
1935 (tree_template_info): Add a field for constraint info.
1936 (tree_constraint_info): New.
1937 (constraint_info_p): New.
1938 (template_info_p): New.
1940 (CI_REQUIREMENTS): New.
1941 (CI_ASSUMPTIONS): New.
1942 (TI_CONSTRAINT): New.
1944 (TI_REQUIREMENTS): New.
1945 (TI_ASSUMPTIONS): New.
1946 (DECL_TEMPLATE_CONSTRAINT): New.
1947 (CLASSTYPE_TEMPLATE_CONSTRAINT): New.
1948 (ENUM_TEMPLATE_CONSTRAINT): New.
1949 (TEMPLATE_TEMPLATE_PARM_TEMPLATE_CONSTRAINT): New.
1950 (TYPE_TEMPLATE_CONSTRAINT): New.
1951 (cp_tree_node_structure_enum): Added entry for constraint info.
1952 (lang_tree_node): Added entry for constraint info.
1953 (lang_decl_base): Added bit for concept declarations.
1954 (DECL_DECLARED_CONCEPT_P): New.
1955 (cp_decl_spec): Added ds_concept declaration specifier.
1956 * gcc/cp/Make-lang.in (logic.o): New target.
1957 * gcc/cp/semantics.c (finish_template_requirements): Rewrite.
1958 * gcc/cp/logic.cc: New
1959 * gcc/cp-tree.def (CONSTRAINT_INFO): New node.
1960 * gcc/cp/pt.c (current_template_args): Make non-static.
1961 (redeclare_class_template): Take constraints as a 3rd argument
1963 2013-04-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1965 * gcc/cp/Make-lang.in: Add constraints.o target.
1966 * gcc/cp/cp-tree.h (substitute_template_parameters): Declare.
1967 (instantiate_requirements): Declare.
1968 (conjoin_requirements): Declare.
1969 (disjoin_requirements): Declare.
1970 (reduce_requirements): Declare.
1971 * gcc/cp/pt.c (substitute_template_parameters): Define.
1972 (instantiate_requirements): Define.
1973 * gcc/cp/pt.c (finish_template_requirements): Call
1974 reduce_requirements to get constraints.
1975 * gcc/cp/parser.c (cp_parser_type_parameter): Restore saved
1976 constraints after parsing template template parameter decl.
1977 * gcc/cp/constraints.cc: New.
1979 2013-03-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1981 * gcc/cp/Make-lang.in: Add constraint.c
1982 * gcc/cp/constraint.c: New
1983 (conjoin_requirements): New
1984 (disjoin_requirements): New
1985 (requirement_reduction): New class
1986 (reduce_requirements): New
1987 * gcc/cp/cp-tree.h (reduce_requrements): New
1988 (conjoin_requirements): New
1989 (disjoin_requirements): New
1990 * gcc/cp/cp-tree.h (finish_template_template_parm) Comments.
1991 * gcc/cp/semantics.c (finish_template_requirements) Start
1992 working with requirements.
1995 2013-03-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1997 * gcc/cp/cp-tree.h (saved_scope): Add template requirements.
1998 (finish_template_requirements): Declare
1999 * gcc/cp/parser.c (cp_parser_template_requirement_opt): Declare.
2000 (cp_parser_template_declaration): Document grammar extensions.
2001 (cp_parser_type_parameter): Parse requirements for template
2002 template parameters.
2003 (cp_parser_member_declaration): Parse requirements for
2004 members of class templates.
2005 (cp_parser_template_requirement_opt): Define.
2006 (cp_parser_template_declaration_after_exp): Parse requirements
2007 for template declarations.
2008 * gcc/cp/semantics.c (finish_template_requirements): Define.
2009 * gcc/cp/lex.c (cxx_init): Enable concepts by default.
2011 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
2013 * lex.c (flag_concepts): Revert left over declaration.
2015 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
2017 * gcc/c-family/c-common.c (cxx_dialect): Set C++11 as default.
2018 * gcc/c-family/c.opt(flag_concepts): Add.
2019 * gcc/cp/lex.c (flag_concepts): New. Enabled concept support by
2022 2013-02-28 Andrew Sutton <andrew.n.sutton@gmail.com>
2024 * gcc/c-family/c-common.h (rid): New resreserved words for concepts.
2025 * gcc/c-family/c-common.c (c_common_reswords): Definitions thereof.
2026 * gcc/doc/extend.texi (write_symbol): Initial concept docs.