1 2015-05-06 Andrew Sutton <andrew.n.sutton@gmail.com>
3 Initial implementation of constrained-type-specifiers for variable
4 declarations. Also updating documentation and style.
5 * gcc/cp/cp-tree.h (make_constrained_auto): New.
6 (evaluate_constraints): New.
7 (check_constraint_epression): Renamed and made static.
8 * gcc/cp/pt.c (do_auto_deduction): Check constraints on
9 constrained placeholders before forming the type.
10 * gcc/cp/parser.c (cp_parser_postfix_expression): Don't
11 allow constrained-type-specifiers within the first term
12 of a postfix expression.
13 (cp_parser_allows_constrained_type_specifier): Removed.
14 (cp_maybe_constrained_type_specifier): Don't process
15 nodes as constrained type specifiers unless they look like
16 constrianed type specifiers, and only when they are allowed.
17 Also, support constrained auto for placeholders. Renamed
18 variables to better reflect usage.
19 gcc/cp/parser.h (struct cp_parser): New member
20 prevent_constrained_type_specifiers.
21 gcc/cp/decl.c (grokfndecl): Remove commented code.
22 gcc/cp/constraint.cc (deduce_constrained_parameter): New.
23 Actually check that template arguments match the concept's
25 (deduce_constrained_parameter): Use deduce_constrained_parameter.
26 (make_constrained_auto): New. Construct an auto with an
28 (check_*_constraint): Renamed to satisfy_*_constraint.
29 (satisfy_constraint): New. Simplify usage in evaluation functions.
30 (evaluate_constraints): New. Normalize and evaluate a constraint.
31 (constraints_satisfied_p): Allow a constraint to be used as
32 an argument in addition to declaraitons.
33 (constraint_expression_satisfied_p): Renamed from
34 check_constraint_expression.
35 (diagnose_*): Use constraint_expression_satisfied_p.
36 (diagnose_decl_constraint): New.
37 (diagnose_constraint): Allow the argument to be a constraint
38 in addition to a declaration.
39 * gcc/testsuite/g++.dg/concepts/mem-concept.C: Renamed to
40 member-concept.C. Updated tests to reflect actual errors.
41 * gcc/testsuite/g++.dg/concepts/mem-concept-err.C: Removed,
42 because it is redundant.
43 * gcc/testsuite/g++.dg/concepts/var-concept5.C: Update error messages.
44 * gcc/testsuite/g++.dg/concepts/placeholder1.C: New.
46 2015-05-05 Andrew Sutton <andrew.n.sutton@gmail.com>
48 Fixing errors in the invention of constrained placeholders
49 and bringing the implementation more into line with the
50 wording of the TS. Also, rewrite comments in C style.
51 * gcc/cp/cp-tree.def (INTRODUCED_PARM_DECL): Renamed to
53 * gcc/cp/cp-tree.h (INTRODUCED_PACK_P): Renamed to
55 (IS_INTRODUCED_PACK): Removed.
56 * cp-objcp-common.c (cp_common_init_ts): Use WILDCARD_DECL.
57 * gcc/cp/pt.c (convert_placeholder_argument): Renamed to
58 convert_wildcard_argument.
59 (coerce_template_parameter_pack): Update for removed macro.
60 gcc/cp/parser.c (cp_parser_introduction_list): Use WILDCARD_DECL.
61 (cp_maybe_constrained_type_specifier): Likewise.
62 (get_concept_from_constraint): Handle VAR_DECLs.
63 gcc/cp/constraint.cc (contains_wildcard_p): New.
64 (build_variable_check): New. Finish processing references to
65 variable templates if the template-id doesn't have wildcards.
66 (build_concept_check_arguments): New. Factor argument construction
67 into a separate function.
68 (build_template_id_check): New. Like build_concept_check, but
69 guarantees preservation of template-ids.
70 (build_concept_check): Use build_variable_check. Refacor to
71 use build_concept_check_arguments.
72 (process_introduction_parm): Use WILDCARD_DECL.
73 * gcc/testsuite/g++.dg/concepts/equiv2.C: Update test.
75 2015-05-04 Andrew Sutton <andrew.n.sutton@gmail.com>
78 * gcc/cp/parser.c (cp_parser_type_requirement): Unwrap alias
79 declarations so they can be checked correctly.
80 * gcc/testsuite/g++.dg/concepts/pr65854.C: New.
82 2015-04-22 Andrew Sutton <andrew.n.sutton@gmail.com>
85 * gcc/cp/cp-tree.h (function_concept_check_p): New.
86 * gcc/cp/call.c (build_new_function_call): Don't evaluate
87 concepts while processing a template.
88 * gcc/cp/constraint.cc (function_concept_check_p): New.
89 * gcc/cp/pt.c (finish_template_variable): Don't evaluate
90 concepts while processing a template.
91 (instantiation_dependent_r): Treat all calls to function
92 concepts as instantiation dependent.
93 * gcc/testsuite/g++.dg/concepts/pr65848.C: New.
94 * gcc/testsuite/g++.dg/concepts/req4.C: Remove extra errors.
95 * gcc/testsuite/g++.dg/concepts/req5.C: Remove extra errors.
97 2015-04-22 Andrew Sutton <andrew.n.sutton@gmail.com>
99 Compare constrained partial specializations structurally.
100 * gcc/pt.c (process_partial_specialization): Don't use a
101 canonical type for constrained partial template specializations.
102 Compare structurally to avoid ICE's when specializations resolve
105 2015-04-20 Andrew Sutton <andrew.n.sutton@gmail.com>
108 * gcc/cp/constraint.cc (tsubst_simple_requirement): Substitute
109 in a template-processing context to avoid doing full resolution
110 on types and expressions.
111 (tsubst_type_requirement): Likewise.
112 (tsubst_compound_requirement): Likewise.
113 (tsubst_nested_requirement): Likewise.
114 * gcc/testsuite/g++.dg/concepts/pr65681.C: New.
115 * gcc/testsuite/g++.dg/concepts/req2.C: Remove check for spurious
118 2015-04-20 Andrew Sutton <andrew.n.sutton@gmail.com>
120 Improve pretty printing output for constraints
121 * gcc/cp/error.c (dump_expr): Print predicate constraints
122 just like other constraints.
123 * gcc/cp/cxx-pretty-print.c (pp_cxx_requirement): Add missing
125 (pp_cxx_requirement_list): Print requirements inline instead
127 (pp_cxx_requirement_body): Don't print a parameter list if
128 there are no parameters.
129 (pp_cxx_nested_requirement): Be less obtuse.
130 (pp_cxx_expression_constraint): Likewise.
131 (pp_cxx_type_constraint) Likewise.
132 (pp_cxx_implicit_conversion_constraint): Likewise.
133 (pp_cxx_argument_deduction_constraint): Likewise.
134 (pp_cxx_parameterized_constraint): Likewise.
135 (pp_cxx_conjunction): Print spaces explicitly.
136 (pp_cxx_disjunction): Likewise.
138 2015-04-17 Andrew Sutton <andrew.n.sutton@gmail.com>
140 Support requires-expressions for variable concepts.
141 * gcc/cp/parser.c (cp_parser_requires_expression): Parse
142 the parameters and body as unevaluated operands.
143 * gcc/cp/pt.c (value_dependent_expression_p): Make all
144 requires-expressions value dependent so we don't try to
145 initialize concepts as if they were actually variables.
146 * gcc/cp/tree.cp (cp_tree_equal): Remove debugging code.
147 * gcc/testsuite/g++.dg/concepts/var-concept1.C: Add tests
150 2015-04-14 Andrew Sutton <andrew.n.sutton@gmail.com>
152 Fix bootstrap regression.
153 * gcc/cp/parser.c (cp_maybe_partial_concept_id): Remove
156 2015-04-13 Andrew Sutton <andrew.n.sutton@gmail.com>
158 Handle partial-concept-ids for variable templates
159 * gcc/cp/parser.c (cp_parser_template_id): Factor the check for
160 variable templates into a new branch that preceeds the check
161 for variable templates and function templates.
162 * gcc/testsuite/g++.dg/concepts/partial.C: Renamed.
163 * gcc/testsuite/g++.dg/concepts/partial-concept-id2.C: New.
165 2015-04-06 Andrew Sutton <andrew.n.sutton@gmail.com>
167 * gcc/cp/constraint.cc (lift_variable_concept): Coerce template
168 arguments before substituting into the initializer.
169 * gcc/cp/pt.c (coerce_template_parms): New overload that accepts
171 * gcc/cp/cp-tree.h (coerce_template_parms): New declaration.
172 * gcc/testsuite/g++.dg/concepts/var-concept5.C: New.
174 2015-04-06 Andrew Sutton <andrew.n.sutton@gmail.com>
176 * gcc/cp/constriant.cc (check_pack_expansion): Don't check
177 same_type_p if the type is null.
178 * gcc/cp/pt.c (process_partial_specialization): Don't allow
179 specialization of variable concepts.
180 * gcc/testsuite/g++.dg/concepts/var-concepts[1-3].C: Renamed to
182 * gcc/testsuite/g++.dg/concepts/var-concept4.C: New.
184 2015-04-03 Andrew Sutton <andrew.n.sutton@gmail.com>
187 * gcc/cp/tree.c (cp_tree_equal): Compare type declrations when
188 ordering constraints.
189 * gcc/testsuite/g++.dg/concepts/pr65635: New.
191 2015-04-03 Andrew Sutton <andrew.n.sutton@gmail.com>
194 * gcc/cp/pt.c (tsubst_decl): Don't try to manage specializations
195 for non-dependent, simple type declarations in namespace scope
196 because they don't have C++ language extensions.
197 * gcc/testsuite/g++.dg/concepts/pr65636: New.
199 2015-04-03 Andrew Sutton <andrew.n.sutton@gmail.com>
202 * gcc/cp/except.c (check_noexcept_r): Check the function type
203 and not the return type for (TYPE_NOTHROW_P).
204 * gcc/cp/parser.c (cp_parser_check_for_invalid_template_id): Remove
205 stray debugging code.
206 * gcc/testsuite/g++.dg/concepts/pr65634: New.
208 2015-04-02 Andrew Sutton <andrew.n.sutton@gmail.com>
210 Fixing constraint processing bugs.
211 * gcc/cp/constraint.cc (check_logical_expr): Use build_x_binary_op
212 so that the c-common doesn't try to fold requires-expressions.
213 * gcc/cp/constexpr.c (cxx_eval_constant_expression): The value
214 of a requires clause is true iff its constraints are satisfied.
215 This lets us check negated requires-expressions.
216 * gcc/testsuite/g++.dg/concepts/req4.C: Update diagnostics
217 * gcc/testsuite/g++.dg/concepts/req5.C: Update diagnostics
218 * gcc/testsuite/g++.dg/concepts/req11.C: New.
220 2015-03-27 Andrew Sutton <andrew.n.sutton@gmail.com>
222 Trying again with PR65575.
223 * gcc/cp/parser.c (cp_parser_declarator): Search through
224 declarator structure for likely matches for function
226 * gcc/testsuite/g++.dg/concepts/pr65575.C: Update with
229 2015-03-25 Andrew Sutton <andrew.n.sutton@gmail.com>
232 * gcc/cp/parser.c (cp_parser_declarator): Don't emit errors
233 when a trailing requires-clause follows a non-function
235 * gcc/testsuite/g++.dg/concepts/pr65575.C: New.
237 2015-03-25 Andrew Sutton <andrew.n.sutton@gmail.com>
239 Fix scope-squashing error in PR65552.
240 * gcc/cp/parser.C (cp_parser_type_requirement): Save and
241 restore scopes around optional nested name specifier parse.
242 * gcc/testsuite/g++.dg/concepts/pr65552.C: New.
244 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
246 Fix bug in disjunction processing and fix the pretty
247 printing for __is_same_as trait correct.
248 * gcc/cp/constraint.cc (check_disjunction): Don't return
249 false if the first condition fails and the second succeeds.
250 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expr): Print the
251 second argument for __is_same_as.
253 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
255 Make implicit conversion constraints handle usual
256 conversions, not just implicit conversions.
257 * gcc/cp/constraint.cc (check_implicit_conversion_constraint):
258 Use perform_direct_initialization_if_possible to test for
259 converibility instead of can_convert_arg.
260 * gcc/testsuite/g++.dg/concepts/req10.C: New.
262 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
264 Suppress errors regarding deleted functions when
266 * gcc/cp/pt.c (tsubst_baselink): Pass complain flags to
268 * gcc/testsuite/g++.dg/concepts/expression3.C: New.
270 2015-03-22 Andrew Sutton <andrew.n.sutton@gmail.com>
272 Fix regression related to variadic templates, bugs in
273 the handling of access checking, and in the logic solver.
274 * gcc/cp/constraint.cc (declare_constraint_vars): Mark
275 constraint variables.
276 (deferring_access_check_sentinel): Make this a local class
277 of check_expression_constraint.
278 (check_type_constraint): Don't defer access checks. Instead
279 pop deferred access checks if they fail.
280 (finish_requires_expr): Mark constraint variables.
281 * gcc/cp/cp-tree.h (CONSTRAINT_VAR_P): Indicates if a
282 parameter is a constraint variable.
283 * gcc/cp/pt.c (pending_expansion_p): New. Helps determine
284 if a parameter will be expanded during substitution.
285 (tsubst_pack_expansion): For certain expressions pending
286 expansion, do that here.
287 (tsubst_decl): Remove dead code.
288 (tsubst_copy_and_build): Don't add arguments that are
289 pending expansion. Also, don't build expansion when the
290 type is dependent. This was causing a regression in
292 * gcc/cp/logic.cc (proof_state::branch): Don't rely on
293 order of operations. This crashed when built with Clang.
294 * gcc/testsuite/g++.dg/concepts/expression2.C: Update to
297 2015-03-21 Andrew Sutton <andrew.n.sutton@gmail.com>
299 Completely suppress access violations occurring from
301 * gcc/cp/constraint.cc (deferring_access_check_sentinel): New helper
302 class for managing deferred access checks.
303 (check_expression_constraint): Explicitly defer constraint checks.
304 (check_type_constraint): Explicitly defer constraint checks.
305 * gcc/testsuite/g++.dg/concepts/expression3.C: New.
307 2015-03-21 Andrew Sutton <andrew.n.sutton@gmail.com>
309 Fail constraints due to access violations in non-SFINAE
311 gcc/cp/constraint.cc (check_expression_constraint,
312 check_type_constraint): Check for access violations.
313 gcc/cp/pt.c (tsubst_decl): Make sure that template
314 info exists before dereferencing it.
315 * gcc/testsuite/g++.dg/concepts/expression2.C: New.
317 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
319 Fix grammar error type requirements and improve diagnostics
320 for mis-defined function concepts and errors involving pack
322 * gcc/cp/pt.c (determine_specialization). Remove dead code.
323 (lookup_template_class_1): Return an error if constraints
325 * gcc/cp/constraint.cc (lift_function_definition): Don't
326 re-check for empty/erroneous concept definitions.
327 (lift_pack_expansion): Removed. Don't inline patterns so
328 that we can preserve the syntax beneath them.
329 (lift_expression): Don't do anything with pack expansions.
330 (check_function_concept): Specifically check for empty
332 (diagnose_pack_expansion): Diagnose errors in expansions
333 more thoughtfully by determining which arguments are failing
334 their expanded requirements.
335 gcc/cp/parser.c (cp_parser_type_requirement): Accept an
336 optional template keyword before a template-id and
337 parse that as a special case of required type name.
338 gcc/testsuite/g++.dg/concepts/template-parm11.C: Update test
339 for fixed grammar, diagnostics.
341 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
343 Ensure that empty expansions are satisfied.
344 * gcc/cp/constraint.cc (check_pack_expansion): Empty expansions
346 * gcc/testsuite/g++.dg/concepts/template-parm11.C: New.
348 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
350 Fix regression in variadic constraint processing.
351 * gcc/cp/pt.c (tsubst_pack_expansion): Expose declaration.
352 * gcc/cp/constraint.cc: Rename lift_constraints to
353 lift_expression to better reflect what it does.
354 (lift_pack_expansion): New. Handles naked pack expansions
356 (check_pack_expansion): Special handling for checking naked
357 pack expansions in constraints. This eventually be replaced
358 by similar logic for fold expressions.
359 (check_predicate_constraint): Handle pack expansions.
360 * gcc/cp/cp-tree.h (tsubst_pack_expansion): Make this avaialble
363 2015-03-18 Andrew Sutton <andrew.n.sutton@gmail.com>
365 Update variable concept processing to account for changes
366 in variable template syntax.
367 * gcc/cp/constraint.cc (valid_predicate_p): Remove because of
369 (make_predicate_constraint): Likewise.
370 (lift_function_call): Check for use of variables in function
371 calls in constraints.
372 (lift_call_expression): Renamed from lift_call. Specifically
373 check function calls before rewriting the node.
374 (lift_variable_concept). Renamed from lift_var. Remove redundant
376 (lift_variable). New. Accommodates new processing rules for
378 (lift_constraints). Add variable decls to the switch.
379 * gcc/cp/pt.c (finish_variable_template): Don't evaluate
380 for dependent template arguments.
381 (remove_constraints): Remove debugging code.
382 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: Separate out
383 failing test into equiv2.C.
384 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: Update error
386 * gcc/testsuite/g++.dg/concepts/equiv2.C: New.
388 2015-03-18 Andrew Sutton <andrew.n.sutton@gmail.com>
390 Addressing regressions after merge.
391 * gcc/cp/parser.c (cp_parser_template_declaration_after_export):
392 Revert implementation of concept introductions. It was causing
394 * gcc/testsuite/g++.dg/concepts/friend1.C: Update test to account
395 for apparent fix (?) to lookup rules involving friends.
397 2015-03-03 Andrew Sutton <andrew.n.sutton@gmail.com>
399 Rewrite to use new constraint model.
400 * gcc/cp/call.c (add_function_candidate): Use new constraint
402 (build_new_function_call): Evaluate concepts when selected
403 by overload resolution.
404 * gcc/cp/class.c (resolve_address_of_overloaded_function):
405 Use new constraint interface.
406 * gcc/cp/constexpr.c (cxx_eval_constant_expression): Don't
407 try to constexpr evaluate a requires-expression.
408 (potential_constant_expression_1): Stop using old
409 requires/constraint features.
410 gcc/cp/constraint.cc: Much rewriting, reorganization, refactoring
411 to support new constraint/requirement terms.
412 (lift_function_definition): New. Factor lifting code out of
413 lift_call for reuse in evaluate_function_concept.
414 (lift_variable_intializer): New. Factor lifting code out of
415 lift_var for reuse in evaluate_variable_concept.
416 (lift_template_id): Restore checking code for mis-written
418 (lift_requires_expr): Handle these separately.
419 (xform_*_requirement): New. Transform requires-expressions
421 (get/set/remove_constraints, decl_constraints): Move to
422 pt.c to allow for garbage collection.
423 (processing_constraint): Kill this global.
424 (diagnose_*): Update diagnostics to use the new constraint
426 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Remove typing
428 * gcc/cp/cp-tree.def: Add new nodes for requirements and
429 constraints. Remove previous constraint/req nodes.
430 gcc/cp/cp-tree.h (COMPOUND_REQ_NOEXCEPT_P): New.
431 (ICONV_CONSTR_EXPR, ICONV_CONSTR_TYPE): Fix operands.
432 (constraint_p, make_predicate_constraint_p, valid_constraints_p): New.
433 (misc): Remove unused declarations.
434 gcc/cp/cxx-pretty-print.c: Reorganize/rewrite for new constraint
436 (primary_expression, expression): Remove unused nodes, add options
438 gcc/cp/cxx-pretty-print.h: Declare new functions for pretty
440 gcc/cp/decl.c (duplicate_decls): Only reclaim when flag_concepts
442 (grokfndecl): Associate predicate constraints.
443 gcc/cp/decl2.c (mark_used): Don't instantiate concepts.
444 gcc/cp/error.c (dump_expr): Handle new constraints.
445 gcc/cp/method.c (implicitly_declare_fn): Use new constraint
447 gcc/cp/parser.c (make_call_declarator): Pass a requires-clause for
449 (cp_parser_type_name): Take a flag to indicate the presence of
450 a pre-parsed 'typename'.
451 (cp_parser_requires_expression): Move sentinel into function.
452 (cp_parser_type_requirement): Parse type requirements in accordance
454 (cp_parser_compound_requirement): Parse compound requirements in
455 accordance with Concepts TS. Remove constexpr requirements.
456 (cp_parser_template_declaration_after_export): Associate
457 predicate constraints.
458 gcc/cp/pt.c (get_template_for_ordering): New. Extract a template
459 decl from a list of candidates.
460 (lookup_template_class_1): Use new constraint interface.
461 (tsubst_pack_conjunction): Build an expression, not constraints.
462 (tsubst_decl): Only associate constraints when substituting
464 (tsubst): Kill subst rules for old nodes.
465 (most_specialized_partial_spec): Save candidates correctly
466 in the presence of constraints.
467 (always_instantiate_p): Never always instantiate a concept.
468 (type_dependent_expression_p): Requires expressions have type bool.
469 (decl_constraints): Moved from constraint.cc, use hash_table
471 gcc/cp/semantics.c (finish_call_expr): Remove constraints from
472 functions, not overload sets.
473 (finish_template_variable): Evaluate variable concepts by
474 determining satisfaction.
475 gcc/cp/typeck.c (cp_build_function_call_vec): Use new concept
477 gcc/cp/testsuite/g++.dg/concepts/*: Update tests to match syntax,
479 gcc/cp/testsuite/g++.dg/concepts/req1.C: Test requires-expression
482 2015-02-25 Braden Obrzut <admin@maniacsvault.net>
484 * gcc/cp/constraint.cc (lift_operands): New.
485 (lift_call): Lift operands on function calls and don't use
486 tsubst_constraint_expr.
487 (lift_var): Don't use tsubst_constraint_expr.
488 (lift_constraints): Use the returned number of operands for most nodes
489 and also lift from TREE_LISTs.
491 2015-02-17 Braden Obrzut <admin@maniacsvault.net>
493 * gcc/cp/constraint.cc (lift_call): Converted from normalize_call.
494 (lift_var): Converted from normalize_var.
495 (lift_template_id): Converted from normalize_template_id.
496 (lift_constraints): Implemented.
498 2015-02-16 Andrew Sutton <andrew.n.sutton@gmail.com>
500 * gcc/cp/cp-tree.h: (EXPR_CONSTR_EXPR, TYPE_CONSTR_TYPE): Fix
501 typos in macro names.
502 * gcc/cp/constraint.cc: (check_constraint*): New. Rewrite the
503 constraint checking implementation so that it matches the
504 wording and rules in n4377.
506 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
508 * gcc/cp/logic.cc: Rewrite to use new constraint model and
510 * gcc/cp/constraint.cc: Documentation and organization.
512 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
514 * gcc/cp/cp-tree.h (is_constraint): Make static.
516 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
518 Rewrite normalization in terms of constraints.
519 * gcc/cp/cp-tree.h (is_constraint): New.
520 * gcc/cp/constraint.cc (normalize_*): Rewrite the previous normalization
521 model so that it conforms with the specification. Normalization applies
522 to constraints. Transformation of expressions into constraints now
523 happens in two phases: lifting concept definitions, and the actual
525 (tranform_expression, xform_*): New. Define transformation of
526 expressions into constraints.
527 (lift_constraints): New. Stubbed out inlining function.
529 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
531 Start refactoring constraints to match the specification.
532 * gcc/cp/cp-tree.def: Add new TREECODEs for constraints.
533 * gcc/cp/cp-tree.h: Add accessor macros for constraint operands.
535 2015-02-05 Braden Obrzut <admin@maniacsvault.net>
537 * gcc/cp/constexpr.c (potential_constant_expression_1): Readded missing
538 cases from previous merge from trunk.
539 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Restored
540 CPTK_IS_CONVERTIBLE_TO for the time being since the constraint code
542 * gcc/cp/semantics.c (finish_trait_expr): Likewise.
543 * gcc/testsuite/g++.dg/concepts/req9.C: New test.
545 2015-02-03 Braden Obrzut <admin@maniacsvault.net>
547 * gcc/cp/class.c (build_clone): Clone constraints.
548 * gcc/cp/constraint.cc (normalize_atom): Update diagnostic.
549 (normalize_constraints): Return error_mark_node if normalization fails.
550 (get_constraints): Access constraints through hash map.
551 (set_constraints): Set constraints through hash map.
552 (remove_constraints): Access constraints through hash map.
553 (associate_classtype_constraints): New.
554 (init_leading_requirements): Removed.
555 (init_trailing_requirements): Removed.
556 (update_leadng_requirements): Removed.
557 (update_trailing_requirements): Removed.
558 (save_leading_constraints): Removed.
559 (save_trailing_constraints): Removed.
560 (finish_template_constraints): Removed.
561 (build_constraints): New. Builds CONSTRAINT_INFO from requirements.
562 (finish_concept_introduction): Check generated parameters for errors.
563 (tsubst_constraint_info): Update implementation.
564 (equivalent_constraints): Check input types.
565 (subsumes_constraints): Update implementation.
566 (at_least_as_constrained): New. Check if a decl's constraints subsumes
568 (diagnose_constraints): Temporarily simplify diagnostics.
569 * gcc/cp/cp-tree.h (tree_constraint_info): Refactor the way constraints
571 (CI_TEMPLATE_REQS): Renamed from CI_LEADING_REQS.
572 (CI_DECLARATOR_REQS): Renamed from CI_TRAILING_REQS.
573 (CI_ASSOCIATED_CONSTRAINTS): New.
574 (CI_NORMALIZED_CONSTRAINTS): New.
575 (CI_ASSOCIATED_REQS): Removed.
576 (saved_scope): Save template requirements.
577 (current_template_reqs): Removed.
578 (lang_decl_min): Replace requires_clause (trailing requirements) with
579 more generic constraint_info.
580 * gcc/cp/cxx-pretty-print.c (cxx_pretty_printer::declarator): Print
582 (pp_cxx_function_definition): Moved requires clause printing to above.
583 (pp_cxx_init_declarator): Likewise.
584 (pp_cxx_template_declaration): Update implementation to get
585 requirements from CONSTRAINT_INFO.
586 * gcc/cp/decl.c (duplicate_decls): Remove constraints before reclaiming
588 (is_class_template_or_specialization): New.
589 (get_leading_constraints): Removed.
590 (adjust_fn_constraints): Removed.
591 (grokfndecl): Update implementation to other changes.
592 (get_trailing_requires_clause): New.
593 (grokdeclarator): Pass trailing requires clause to grokfndecl.
594 (xref_tag_1): Check overload constraints.
595 * gcc/cp/error.c (dump_template_decl): Print requires clause.
596 (dump_function_decl): Update implementation for accessing requirements.
597 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Update
598 CI_ASSOCIATED_REQS usage.
599 * gcc/cp/method.c (implicitly_declare_fn): Copy constraints of
600 inherited constructors.
601 * gcc/cp/parser.c (cp_parser_lambda_expression): Remove now unneeded
602 template requirements saving.
603 (cp_parser_type_parameter): Likewise.
604 (cp_parser_template_argument_list): Unwrap template_template_parms when
605 produced by short hand notation with function concepts.
606 (cp_parser_alias_declaration): Attach constraints to aliases.
607 (cp_manage_requirements): Removed.
608 (cp_parser_trailing_requirements_clause): Renamed from
609 cp_parser_trailing_requirements.
610 (cp_parser_init_declarator): Removed now unneeded requirements saving.
611 (cp_parser_basic_declarator): Separated from cp_parser_declarator.
612 (cp_parser_declarator): Parses trailing requires clause if
613 cp_parser_basic_declarator succeeds.
614 (cp_parser_class_specifier_1): Associate constaints with type.
615 (cp_parser_member_declaration): Remove unneeded template requirement
617 (cp_parser_template_declaration_after_export): Likewise.
618 (cp_parser_single_declaration): Associate constraints.
619 (cp_parser_late_parsing_for_member): Remove unneeded template
621 (synthesize_implicit_template_parm): Likewise.
622 * gcc/cp/pt.c (maybe_new_partial_specialization): Update
624 (process_template_parm): Removed unneeded template requirement saving.
625 (build_template_decl): Handle constraints.
626 (process_partial_specialization): Update constraint access and check
627 that specialization is more specialized.
628 (push_template_decl_real): Update constraint access.
629 (add_inherited_template_parms): Removed constraint handling.
630 (tsubst_pack_conjuction): Update implemenation.
631 (tsubst_decl): Changed constraint propagation.
632 (more_specialized_fn): Update constraint access.
633 (most_specialized_partial_spec): Update constraint access.
634 * gcc/cp/ptree.c (cxx_print_xnode): Update constraint access.
635 * gcc/cp/semantics.c (finish_call_expr): Remove constraints.
636 (finish_template_template_parm): Update constraint access.
637 * gcc/testsuite/g++.dg/concepts/alias4.C: Mark xfail.
638 * gcc/testsuite/g++.dg/concepts/class.C: Check for escape hatch.
639 * gcc/testsuite/g++.dg/concepts/class6.C: Added diagnostic.
640 * gcc/testsuite/g++.dg/concepts/inherit-ctor1.C: Improved test case.
641 * gcc/testsuite/g++.dg/concepts/inherit-ctor2.C: Updated diagnostic.
642 * gcc/testsuite/g++.dg/concepts/inherit-ctor4.C: Updated diagnostic.
643 * gcc/testsuite/g++.dg/concepts/intro4.C: Updated diagnostics.
644 * gcc/testsuite/g++.dg/concepts/req4.C: Updated diagnostic.
645 * gcc/testsuite/g++.dg/concepts/req5.C: Updated diagnostic.
647 2014-12-29 Jason Merrill <jason@redhat.com>
649 * gcc/cp/pt.c (type_dependent_expression_p): Remove obsolete use of
651 (convert_template_argument): Likewise.
653 2014-11-15 Braden Obrzut <admin@maniacsvault.net>
655 * gcc/cp/constraint.cc (resolve_constraint_check): Move definition
657 (normalize_template_id): Use expression location if available when
658 informing about missing parentheses.
659 (build_requires_expr): Added comment.
660 (diagnose_var): Clarified comment.
661 * gcc/cp/decl.c (check_concept_refinement): Remove outdated comment
662 regarding variable concepts.
663 (grokfndecl): Ensure that all concept declarations are definitions.
664 (grokdeclarator): Remove outdated comment regarding variable concepts.
665 * gcc/cp/parser.c (cp_parser_introduction_list): Use vec for temporary
666 list instead of a TREE_LIST.
667 (get_id_declarator): Renamed from cp_get_id_declarator.
668 (get_unqualified_id): Renamed from cp_get_identifier.
669 (is_constrained_parameter): Renamed from cp_is_constrained_parameter.
670 (cp_parser_check_constrained_type_parm): Renamed from
671 cp_check_constrained_type_parm.
672 (cp_parser_constrained_type_template_parm): Renamed from
673 cp_constrained_type_template_parm.
674 (cp_parser_constrained_template_template_parm): Renamed from
675 cp_constrained_template_template_parm.
676 (constrained_non_type_template_parm): Renamed from
677 cp_constrained_non_type_tmeplate_parm.
678 (finish_constrained_parameter): Renamed from
679 cp_finish_constrained_parameter.
680 (maybe_type_parameter): Renamed from cp_maybe_type_parameter.
681 (declares_type_parameter): Renamed from cp_declares_type_parameter.
682 (declares_type_template_parameter): Renamed from
683 cp_declares_type_template_parameter.
684 (declares_template_template_parameter): Renamed from
685 cp_declares_template_template_parameter.
686 (cp_parser_type_parameter): Call
687 cp_parser_default_type_template_argument and
688 cp_parser_default_template_template_argument which were already
689 factored out from this function.
690 (cp_maybe_constrained_type_specifier): Use the new INTRODUCED_PARM_DECL
691 instead of PLACEHOLDER_EXPR.
692 (cp_parser_requires_expr_scope): Remove old comment and change
693 destructor to use pop_bindings_and_leave_scope.
694 (cp_parser_requires_expression): Remove old comment.
695 (get_concept_from_constraint): Remove old comment.
696 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Changed expected
697 errors now that missing concept definitions are diagnosed earlier.
699 2014-11-11 Jason Merrill <jason@redhat.com>
701 * gcc/cp/call.c (add_function_candidate): Move constraint check after
704 * gcc/cp/class.c (get_member_fn_template)
705 (are_constrained_member_overloads): Remove.
706 (add_method): Call equivalently_constrained directly.
708 2014-11-03 Jason Merrill <jason@redhat.com>
710 * gcc/cp/parser.c (cp_parser_nonclass_name): Fix merge error.
712 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
714 Fixing user-reported issues and regressions
715 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
716 Only pop access checks on failed parsing.
717 * gcc/cp/pt.c (type_dependent_expr_p): Always treat a
718 requires-expr as if dependently typed. Otherwise, we try to
719 evaluate these expressions when they have dependent types.
720 * gcc/cp/constriant.cc (normalize_stmt_list): Remove unused
722 (normalize_call): Don't fold constraints during normalization.
723 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Update diagnostics.
725 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
727 Fix another introduction regression.
728 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
729 Only pop access checks on failed parsing.
731 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
733 Fix regression related to concept introductions.
734 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
735 Pop deferred access checks afer parsing the introduction.
737 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
739 Fix bug related to cleanup expressions in concept definitions.
740 * gcc/cp/constraint.cc (check_function_concept): See through
741 cleanup handlers when checking the body of a function.
742 (normalize_cast): Removed. Handled in a default case.
743 (normalize_cleanup_point): New. Normalize the expression without
746 2014-09-25 Andrew Sutton <andrew.n.sutton@gmail.com>
748 Explicitly disallow function concepts with deduced return types.
749 * gcc/cp/constraint.cc (check_function_concept): Remove check
750 for deduced return type.
751 * gcc/cp/decl.c (check_concept_fn): Explicitly check for
753 * gcc/testsuite/g++.dg/concepts/fn-concept2.C: New.
755 2014-09-24 Andrew Sutton <andrew.n.sutton@gmail.com>
757 Check requirements on function concept definitions.
758 * gcc/cp/decl.c (finish_function): Check properties of a function
760 * gcc/cp/constraint.cc (check_function_concept): New. Check
761 for deduced return type and multiple statements.
762 (normalize_misc): Don't normalize multiple statements.
763 (normalize_stmt_list): Removed.
764 * gcc/cp/cp-tree.h (check_function_concept): New.
765 * gcc/testsuite/g++.dg/concepts/fn-concept1.C: New.
767 2014-09-04 Braden Obrzut <admin@maniacsvault.net>
769 Implement concept introductions.
770 * gcc/cp/constraint.cc (deduce_concept_introduction): New.
771 (build_concept_check): Allow arg to be NULL to skip placeholder.
772 (process_introduction_parm): New.
773 (finish_concept_introduction): New.
774 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Mark introduced parm.
775 * gcc/cp/cp-tree.def: New INTRODUCED_PARM_DECL.
776 * gcc/cp/parser.c (cp_parser_declaration): Tentatively parse for
777 concept introduction.
778 (cp_parser_introduction_list): New.
779 (cp_parser_member_declaration): Tentatively parse for concept
781 (cp_parser_template_introduction): New.
782 (cp_parser_template_declaration_after_export): Parse concept
784 * gcc/cp/pt.c (convert_template_argument): Treat INTRODUCED_PARM_DECL
786 (coerce_template_parms): If INTRODUCED_PARM_DECL represents a pack then
787 match the entire parameter pack of the template.
788 (type_dependent_expression_p): Treat INTRODUCED_PARM_DECL as a
790 * gcc/testsuite/g++.dg/concepts/introduction1.C: New.
791 * gcc/testsuite/g++.dg/concepts/introduction2.C: New.
792 * gcc/testsuite/g++.dg/concepts/introduction3.C: New.
793 * gcc/testsuite/g++.dg/concepts/introduction4.C: New.
794 * gcc/testsuite/g++.dg/concepts/introduction5.C: New.
796 2014-09-01 Andrew Sutton <andrew.n.sutton@gmail.com>
798 Fixing normalization in the presence of constructor calls.
799 * gcc/cp/constraint.cc (normalize_misc): Handle constructor
801 * gcc/testsuite/g++.dg/concepts/req7.C: New.
803 2014-08-29 Andrew Sutton <andrew.n.sutton@gmail.com>
805 Fixing partial-template-id bug.
806 * gcc/cp/parser.c (cp_parser_type_name): If the returned type-decl
807 is actually a shorthand declaration, don't simulate an error.
808 * gcc/testsuite/g++.dg/concepts/template-parm10.C: New.
810 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
812 Add tests for constrained friends.
813 * gcc/testsuite/g++.dg/concepts/friend1.C: New.
814 * gcc/testsuite/g++.dg/concepts/friend2.C: New.
816 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
818 * gcc/cp/decl.c (is_concept_var): Coding style fix.
820 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
822 Fixing regression in scoping rules for templates.
823 * gcc/cp/semantics.c (fixup_tmeplate_type): Lift check to
824 finish_template_type.
825 (finish_template_type): Only do this when concepts are enabled,
826 and also when the class is actually a template. For non-dependent
827 types there are no actions to be taken.
829 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
831 Additional declaration restrictions on variable concepts.
832 * gcc/cp/decl.c (is_concept_var): New.
833 (cp_finish_decl): Check for uninitialized variable
835 (grokvardecl): Don't set the concept flag for non-template variables.
836 * g++.dg/concepts/decl-diagnose.C: Add tests.
838 2014-08-19 Ville Voutilainen <ville.voutilainen@gmail.com>
840 Ban static member function concepts.
841 * gcc/cp/decl.c (grokdeclarator): Diagnose static member function
843 * g++.dg/concepts/decl-diagnose.C: Adjust.
844 * g++.dg/concepts/mem-concept-err.C: Adjust.
845 * g++.dg/concepts/mem-concept.C: Adjust.
847 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
849 Fixes to variable concept implementation.
850 * gcc/cp/cp-tree.h (variable_concept_p): New.
851 * gcc/cp/parser.c (cp_parser_nonclass_name): Check for concepts,
853 * gcc/cp/decl.c (grokvardecl): Label concepts as concepts.
854 * gcc/cp/constraint.cc (check_call): New.
855 (normalize_call): Ensure that calls are probably to functions.
856 (normalize_template_id): Update diagnostics.
857 (finish_template_constraints): Mark assumptions as an error if
858 constraint normalization fails. This was causing normalization
859 to be run twice during the construction of a single declaration.
860 * gcc/testsuite/g++.dg/concepts: Update tests.
862 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
865 * gcc/cp/pt.c (value_dependent_expression_p): Don't assume
866 that all nodes have operands.
868 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
870 Implement normalization checks.
871 * gcc/cp/constraint.cc (normalize_expr): Delegate cast and
872 atomic nodes to a dedicated function.
873 (check_logical): Check that an && or || does not resolve to a
874 user-defined function.
875 (normalize_logical): Check operators and save the locaiton of
877 (normalize_call, normalize_var): Remove spurios error messages.
878 (normalize_cast): New, delegates to normalize atom.
879 (normalize_atom): Check that instantiated expressions can be
881 (tsubst_constraint_info): Re-normalize the associated constraints
882 to check for post-substitution restrictions.
883 * gcc/cp/cp-tree.h (xvalue_result_type): Add to header.
885 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
887 * gcc/testsuite/g++.dg/concepts: Renamed ttp* to template-parm*,
890 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
892 * gcc/cp/class.c (resolve_address_of_overloaded_function): Check
894 * gcc/cp/decl.c (grokfndecl): For now, disallow constrained
895 non-template functions.
896 * gcc/testsuite/g++.dg/concepts: New tests.
898 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
900 * gcc/cp/parser.c (get_id_declarator, get_identifier): New helper
902 (cp_check_constrained_type_parm): Don't fail on null declarators.
903 (cp_finish_constrained_parameter): Remove redundant processing for
904 checking declarations.
905 (cp_maybe_type_parameter, cp_declares_type_parameter,
906 cp_declares_type_template_parameter,
907 cp_declares_template_template_parameter): New helper functions for
908 determining when a parameter declaration is actually a constrained
910 (cp_parser_default_type_template_argument,
911 cp_parser_default_template_template_argument): Parsing support
912 for argument types of default arguments.
913 (cp_parser_template_parameter): Finish constrained parameters
914 after all variadic and default arg checks.
915 (cp_parser_parameter_declaration): Parse default arguments
916 differently if the parameter actually declares a type parameter.
917 * gcc/testsuite/g++.dg/concepts: New tests.
919 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
921 * gcc/testsuite/g++.dg/concepts/explicit-spec6.C: New test.
923 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
925 Fix regression in bootstrap.
926 * gcc/cp/call.c (get_temploid): Removed. No longer called.
927 (joust): Remove unused variable declarations.
929 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
931 Implement deduction-based explicit instantiation and specialization.
932 * gcc/cp/call.c (joust): Allow all non-templates to be ordered by
934 * gcc/cp/pt.c (get_class_bindings): Remove superfluous parameter and
935 move constraint check into most_specialized_class.
936 (most_constrained_function): Order functions with the same signatures
937 by their constraints.
938 (determine_specialization): Candidates must satisfy constraints. Also,
939 order non-template candidates by constraints. Improve diagnostics
940 for instances where candidates are rejected.
941 (more_specialized_inst): New. Compare function templates.
942 (most_specialized_instantiation): Refactor to use
943 more_specialized_inst and order by constraints.
944 (most_specialized_class): Candidates must satisfy constraints.
945 * gcc/cp/decl.c (various) Cosmetic fixes.
946 (adjust_fn_constraints): Rewrite so that class template constraints
947 are not imposed on member function declarations.
948 * gcc/testsuite/g++.dg/concepts: New tests.
950 2014-08-13 Braden Obrzut <admin@maniacsvault.net>
952 * gcc/cp/constraint.cc (deduce_constrained_parameter): Deduce concept
953 from variable concept template-id expressions.
954 (normalize_var): New.
955 (normalize_template_id): Identify variable concepts.
956 (build_concept_check): Handle variable concepts.
957 (finish_shorthand_requirement): Handle variable concepts.
959 (diagnose_node): Identify variable concepts.
960 * gcc/cp/decl.c (grokvardecl): Pass concept flag through to
961 check_explicit_specialization.
962 (grokdeclarator): Allow variable concepts and pass concept flag through
964 * gcc/cp/parser.c (cp_is_constrained_parameter): Accept variable
966 (cp_parser_nonclass_name): Accept variable concepts.
967 (get_concept_from_constraint): Handle variable concepts.
968 * gcc/cp/pt.c (tsubst_copy_and_build): Lookup variable templates.
969 (value_dependent_expression_p): Check requires expressions for value
971 * gcc/cp/semantics.c (finish_call_expr): Don't instantiate variable
972 templates if processing a template declaration.
973 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Change expected error
974 as variable concepts are now handled.
975 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: New test.
976 * gcc/testsuite/g++.dg/concepts/var-concepts2.C: New test.
978 2014-08-11 Andrew Sutton <andrew.n.sutton@gmail.com>
980 * gcc/cp/pt.c (tsubst): Don't short circuit substitution into
981 types when processing constraints. Also, avoid asserting when
982 substituting into template parameters.
983 * gcc/cp/constraint.c (tsubst_constraint_expr): Indicate that
984 constraint processing is happening.
985 (tsubst_constraint_info): Just substitute directly into the
986 normalized constraints instead of re-normalizing.
987 (diagnose_constraints): Adjust template arguments when
988 diagnosing template constraint failures.
989 * gcc/cp/logic.cc (decompose_assumptions): Handle null assumptions.
991 2014-08-08 Andrew Sutton <andrew.n.sutton@gmail.com>
993 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Don't re-normalize
994 constraints, it's already been done.
995 * gcc/cp/cp-tree.h (*_requirement[s]): Renamed to *_constraint[s] to
996 reflect wording in specification. Removed reduce_requirements.
997 * gcc/cp/pt.c (process_template_parm, tsubst_pack_conjunction): Update
999 (fn_type_unification): Remove constraint check.
1000 * gcc/cp/parser.c (cp_parser_type_parameter,
1001 cp_parser_trailing_requirements,
1002 cp_parser_template_declaration_after_export,
1003 synthesize_implicit_template_parm): Update from renaming.
1004 * gcc/cp/constraint.cc: Renamed a lot of functions to reflect wording
1006 (finish_template_constraints): Normalize associated constraints.
1007 (tsubst_constraint_expr): Renamed from instantiate_requirements.
1008 Normalize associated constraints.
1009 (check_satisfied): Return true if the arguments refer to template
1011 (all_constraints_satisfied, any_conjunctions_satisfied,
1012 check_requirements): No longer needed.
1013 (check_diagnostic_constraints): Just normalize the expression, don't
1016 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
1018 * gcc/testsuite/g++.dg/concepts/concepts.exp: Add missing argument
1021 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
1023 * gcc/cp/constraints.c (tsubst_requires_body, instantiate_requirements):
1024 Lift the unevaluated operand guard to the entire constraint expression.
1025 (check_satisfied, all_constraints_satisfied,
1026 any_conjunctions_satisfied): Rewrite constraint checking to use
1027 atomic constraints. Prevents instantiation of concepts.
1028 (check_diagnostic_constraints): Recursively decompose and check
1029 constraints for fine-grain diagnostics.
1030 (diagnose_*): Use new constraint checking function.
1033 2014-07-30 Braden Obrzut <admin@maniacsvault.net>
1035 * gcc/cp/parser.c (cp_parser_trailing_requirements): Handle requires
1036 keyword manually so that we can push function parameters back into
1038 * gcc/cp/decl.c (push_function_parms): New. Recovers and reopens
1039 function parameter scope from declarator.
1040 * gcc/testsuite/g++.dg/concepts/req*.C: New tests.
1042 2014-07-30 Andrew Sutton <andrew.n.sutton@gmail.com>
1044 * gcc/testsuite/g++.dg/concepts/test.C: Removed.
1046 2014-07-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1048 * gcc/cp/cp-tree.h (more_constraints): Remove
1049 (subsumes_constraints): Renamed from more_constraints
1050 (more_constrained): Repurposed
1051 * gcc/cp/call-c (template_decl_for_candidates): Rename to get_temploid,
1052 only get template info for member functions of a class template
1054 (joust): Handle member functions of class template specializations
1055 separately from function templates. This matches the new wording in
1057 * gcc/cp/logic.cc (match_terms): Make inline.
1058 (subsumes_constraints): Rename to subsumes_constraints_nonnull.
1059 * gcc/cp/pt.c (is_compatible_template_arg): Use subsumes.
1060 (more_specialized_fn): Use usubsumes_constraints.
1061 (more_specialized_class): Use more_constrained.
1062 * gcc/cp/constraint.cc (more_constraints): Removed.
1063 (more_constrained): New.
1065 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1067 * gcc/cp/typeck.c (cp_build_function_call_vec): Emit diagnostic
1068 at the input location.
1069 * gcc/cp/error.c (dump_template_decl): Constraints are never invalid
1070 in this way. Also fixes brace warning.
1072 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1074 * gcc/cp/tree.c (cp_tree_equal): compare constraint infos by
1075 their associated constraints (patch by Braden Obrzut).
1076 * gcc/cp/logic.c (decompose_assumptions): Don't decompose errors.
1077 (subsumes_constraints): Update to use new macros.
1078 * gcc/cp/cp-tree.h (tree_constraint_info): Rewrite constraints
1079 to cache leading, trailing, and associated requirements.
1080 (CI_SPELLING, CI_REQUIREMENTS): Remove
1081 (CL_LEADING_REQS, CI_TRAILING_REQS, CI_ASSOCIATED_REQS): New
1082 accessors for constraint info field.
1083 (save_leading_requirements, save_trailing_requirements,
1084 valid_template_requirements_p): New.
1085 (make_constraints): Removed.
1086 (instantiate_requirements): Add flag to substitute in either
1087 dependent/non-dependent mode.
1088 (tsubst_constraint_info): New.
1089 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_clause): New.
1090 * gcc/cp/cxx-pretty-print.c (pp_cxx_init_declarator): Remove.
1091 (pp_cxx_function_definition): Print trailing constraints if they
1093 (pp_cxx_init_declarator): New. Print trailing requirements.
1094 (pp_cxx_template_declaration): Print leading requirements.
1095 (pp_cxx_requires_clause): New.
1096 * gcc/cp/pt.c (build_template_decl): Ensure completion of constraints
1097 when associating them with the template.
1098 (add_inherited_template_parms): Update to new constraint mechanisms.
1099 (redeclare_class_template): Update to new constraint mechanisms.
1100 (tsubst_decl): Update to new constraint mechanism.
1101 * gcc/cp/parser.c (cp_parser_lambda_expression): Save off constraints
1102 in a generic lambda.
1103 (cp_check_constrained_type_parm): Save leading requirements instead
1105 (cp_parser_trailing_requirements): Simplify by just saving the trailing
1107 (cp_parser_init_declarator): Save off constraints before parsing the
1109 (cp_parser_member_declaration): Save off requirements before parsing
1111 (cp_parser_requires_clause): Defer constexpr check until as late as
1113 (cp_parser_template_declaration_after_export): Save leading requirements
1114 instead of finishing them.
1115 (synthesize_implicit_template_parm): Save leading requirements when
1116 processing a constrained-type-specifier.
1117 * gcc/cp/class.c (get_member_fn_template): Update to use new constraint
1119 * gcc/cp/call.c (constraint_failure): Renamed from
1120 template_constraint_failure. Produce reasons for non-template functions.
1121 (is_constrainable_non_template_fn): Removed.
1122 (add_function_candidate): Use new constraint association framework.
1123 * gcc/cp/ptree.c (cxx_print_xnode): Dump leading, trailing requirements.
1124 * gcc/cp/error.c (dumpl_template_decl): Print a leading requires-clause.
1125 (dump_function_decl): Print a trailing requires-clause.
1126 * gcc/cp/semantics.c (finish_template_template_parm): Finish
1127 template constraints before associating them.
1128 * gcc/cp/constraint.cc (reduce_call): Don't fold constants when
1130 (reduce_template_id): Replace EXPR_LOCATION in diagnostics. Return
1131 error_mark_node instead of corrected call expression.
1132 (reduce_requirements): Don't normalize a null expression.
1133 (make_constraints): Removed.
1134 (get_constraints): Updated.
1135 (set_constraint): Updated.
1136 (get_shorthand_requirements): Use the appropriate macro.
1137 (build_constraint_info, init_leading_requirements,
1138 init_trailing_requirements, update_leadng_requirements,
1139 update_trailing_requirements, save_leading_requirements,
1140 save_trailing_requirements): New.
1141 (finish_template_requirements): Analyze and decompose constraints.
1142 (valid_template_requirements_p): New.
1143 (instantiate_requirements): New flag.
1144 (tsubst_constraint_info): New.
1145 (check_requirements): Update.
1146 (check_constraints): Add another round of instantiation to ensure
1147 that all non-constexpr exprs are folded out of the expression.
1148 (check_constraints): Update.
1149 (equivalent_constraints): Redefine constraint equivalence in terms
1150 of tokens (patch by Braden Obrzut).
1151 (diagnose_trait, diagnose_check, diagnose_requires,
1152 diagnose_constraints): Update.
1153 * gcc/cp/decl2.c (check_classfn): Update constraint mechanisms.
1154 * gcc/cp/decl.c (decls_match): Update to use new constraints.
1155 (duplicate_decls): members match if they have equivalent constraints.
1156 (get_leading_template_requirements): New.
1157 (adjust_out_of_class_fn_requirements): New.
1158 (grokfndecl): Associate requirements with a function declaration.
1159 * gcc/testsuite/g++.dg/concepts/*: New tests.
1161 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1163 * gcc/c-family/c.opt (flag_concepts): Don't enable by default.
1164 * gcc/c-family/c-opts.c (set_std_cxx1z): Enable concepts if
1165 -std=cxx1z is selected.
1166 * gcc/c-family/c-format.c (gcc_cxxdia): Add "Z" as format specifier.
1167 * gcc/cp/c-common.c (cxx_dialect): Make -std=c++98 the default
1169 * gcc/cp/lex.c (cxx_init): Don't set flag_concepts explicitly.
1170 * gcc/testsuite/g++.dg/concepts/*.C: Update build flags.
1172 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1174 * gcc/cp/cp-tree.h (DECL_CONSTRAINTS): Remove this macro; use
1175 get_constraints instead.
1176 (set_constraints): new.
1177 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Use
1179 * gcc/cp/pt.c (get_specialization_constraints): Use get_constraints.
1180 (build_template_decl): Use get_constraints.
1181 (process_partial_specialization): Use get_constraints.
1182 (add_inherited_template_parms): Use get_constraints.
1183 (redeclare_class_template): Use get_constraints.
1184 (is_compatible_template_arg): Use get_constraints.
1185 (tsubst_friend_class): Use get_constraints.
1186 (tsubst_decl): Uset get_constraints.
1187 * gcc/cp/semantics.c (finish_template_template_parm): Use
1189 (fixup_template_type): Use get_constraints.
1190 * gcc/cp/constraint.cc (constraints): New global association
1191 of declarations to constraints.
1192 (get_constraints): Return the associated constraints from the
1194 (set_constraints): New. Associate constraints with a declaration.
1195 (check_template_constraints): Use get_constraints.
1196 (equivalently_constrained): Use get_constraints.
1197 (more_constrained): Use get_constraints.
1198 (diagnose_constraints): Use get_constraints.
1199 * gcc/testsuite/g++.dg/concepts/partial-spec.C: New.
1201 2014-06-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1203 * gcc/cp/parser.c (cp_parser_requires_clause): Don't fold expressions
1204 when parsing a requires-clause.
1205 * gcc/cp/constraint.cc (reduce_requirements): Don't fold
1206 expressions during constraint normalization.
1208 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1210 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): Defer
1211 handling the BASELINK check until concept-resolution in order to
1212 allow member conceps.
1213 (cp_parser_nonclass_name): Also Check for concept-names when the
1214 lookup finds a BASELINk.
1215 * gcc/cp/constraint.cc: (resolve_constraint_check) If the call
1216 target is a base-link, resolve against its overload set.
1217 (build_concept_check): Update comments and variable names to
1218 reflect actual processing.
1219 * gcc/testuite/g++.dg/concepts/mem-concept.C: New test.
1220 * gcc/testuite/g++.dg/concepts/mem-concept-err.C: New test.
1222 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1224 * gcc/cp/error.c (dump_expr): Pretty print placeholder to improve
1227 2014-06-17 Braden Obrzut <admin@maniacsvault.net>
1229 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): If getting
1230 a baselink, use the referred-to function/overload declarations rather
1233 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
1235 * gcc/cp/constraint.cc (deduce_constrained_parameter): Refactor
1236 common deduction framework into separate function.
1237 (build_call_check): New.
1238 (build_concept_check): Take additional arguments to support the
1239 creation of constrained-type-specifiers from partial-concept-ids.
1240 (build_constrained_parameter): Take arguments from a partial-concept-id.
1241 * gcc/cp/cp-tree.h (build_concept_check, biuld_constrained_parameter):
1242 Take a template argument list, defaulting to NULL_TREE.
1243 * gcc/cp/parser.c (cp_parser_template_id): Check to see if a
1244 template-id is a concept check.
1245 (cp_check_type_concept): Reorder arguments
1246 (cp_parser_allows_constrained_type_specifier): New. Check contexts
1247 where a constrained-type-specifier is allowed.
1248 (cp_maybe_constrained_type_specifier): New. Refactored common rules
1249 for concept name checks.
1250 (cp_maybe_partial_concept_id): New. Check for
1251 constrained-type-specifiers.
1252 * gcc/testuite/g++.dg/concepts/partial.C: New tests.
1253 * gcc/testuite/g++.dg/concepts/partial-err.C: New tests.
1254 * gcc/testuite/g++.dg/concepts/concepts.exp: Add missing test driver.
1256 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
1258 * gcc/cp/parser.c (cp_check_type_concept): New.
1259 (cp_check_concept_name): Remove redundant condition from check.
1260 Diagnose misuse of non-type concepts in constrained type specifiers.
1261 * gcc/testuite/g++.dg/concepts/generic-fn.C: Add tests for
1262 non-simple constrained-type-specifiers and nested-name-specifiers
1264 * gcc/testuite/g++.dg/concepts/generic-fn-err.C: New tests for
1265 diagnosing ill-formed programs.
1267 2014-06-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1269 * gcc/cp/cp-tree.h (build_constrained_parameter): Renamed fro
1270 describe_tempalte_parm.
1271 * gcc/cp/parser.c (cp_check_constrained_type_parm): New. Prevent
1272 declaration of cv-qualifed or non-id types.
1273 (cp_constrained_type_template_parm): Renamed, check for invalid
1275 (cp_constrained_template_template_parm): Renamed, check for invalid
1277 (cp_constrained_non_type_tmeplate_parm): Renamed.
1278 (cp_finish_constrained-parameter): Support checking of decarlarations.
1279 (cp_check_concept_name): Renamed. Add initial support for auto
1280 and constrained-type-specifiers in compound requirements.
1281 (cp_parser_nonclass_name): Only check for concept names if -fconcepts
1283 (cp_manage_requirements): New RAII guard for managinging the
1284 current_template_reqs variable during declaration parsing.
1285 (cp_paresr_trailing_requirements): Refactored common parsing
1286 requirements from cp_parser_init_declarator and
1287 cp_parser_member_declarator. Take terse constraints from implicit
1288 parameter declarations.
1289 (cp_parser_init_declarator): Cleanup, refactor requirement logic.
1290 (cp_parser_type_id_1): Allow auto in compound requirements.
1291 (cp_parser_member_declaration): Cleanup, refactor requirement logic.
1292 (cp_parser_compound_requirement): Note parsing state for the
1293 trailing-type-id so we can get auto and constrained-type-specifiers.
1294 (cp_parser_function_definition_after_decl): Remove broken constraint
1296 * gcc/cp/parser.h (cp_parser): New member.
1297 * gcc/cp/constraint.cc (finish_validtype_expr): Initial (non-)handling
1298 of auto in type requirements.
1299 (finish_concept_name): Moved to cp_check_concept_name.
1300 * gcc/testuite/g++.dg/concepts/constrained-parm.C: New test.
1301 * gcc/testuite/g++.dg/concepts/generic-fn.C: New test.
1304 2014-03-10 Andrew Sutton <andrew.n.sutton@gmail.com>
1306 * gcc/testuite/g++.dg/concepts/fn1.C: New test.
1307 * gcc/testuite/g++.dg/concepts/fn2.C: New test.
1309 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1311 * gcc/cp/parser.c (synthesize_implicit_template_parm): Allow concepts
1312 to declare implicit template parameters. Only synthesize new parameters
1313 if the concept name is new.
1314 (finish_concept_name): Moving into parser.c for the time being. Needs
1315 to be rewritten to remove duplicate code between parser.c and
1318 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1320 * gcc/cp/pt.c (tsubst_copy): Expand pack expansions as conjunctions.
1322 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1324 * gcc/cp/pt.c (tsubst_pack_conjunction): Don't try to conjoin
1325 dependent expressions.
1327 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1329 * gcc/cp/semantics.c (fixup_template_type): Compare primary template
1330 types to specializations using structural types so we don't run into
1331 canonical type errors with constrained specializations.
1333 2013-11-08 Andrew Sutton <andrew.n.sutton@gmail.com>
1335 * gcc/cp/pt.c (add_inherited_template_parms): Instantiate requirements
1336 in a processing template decl context.
1338 2013-11-05 Andrew Sutton <andrew.n.sutton@gmail.com>
1340 * gcc/cp/semantics.c (fixup_template_type): Add a same-type check
1341 for specialiations so we don't accidentally match non-dependent
1342 specializations having a different type.
1344 2013-10-26 Ville Voutilainen <ville.voutilainen@gmail.com>
1346 * gcc/cp/decl.c (grokdeclarator): Reject concept keyword
1347 in typedefs, function parameters, data members, non-static
1348 member functions and variables. Allow static member functions
1351 2013-10-30 Andrew Sutton <andrew.n.sutton@gmail.com>
1353 * gcc/cp/semantics.c (fixup_template_type): Don't emit errors when
1354 no templates can be found with matching constraints.
1356 2013-10-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1358 * gcc/cp/parsre.c (cp_parser_requires_expression): Gracefully
1359 fail when parsing a requires expr outside a template.
1361 2013-10-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1363 * gcc/cp/c-common.c (c_common_r): Remove unused keywords "assume",
1364 "axiom", and "forall".
1365 * gcc/cp/c-common.h (rid): Removed unused reserved word ids.
1367 2013-10-24 Edward Smith-Rowland <3dw4rd@verizon.net>
1369 * gcc/cp/typeck.c (cp_build_function_call_vec): Use unused variable
1372 2013-10-23 Andrew Sutton <andrew.n.sutton@gmail.com>
1374 * gcc/cp/class.c (get_member_fntemplate): New.
1375 (are_constrained_member_overloads): Only get a template declaration
1376 if the member function is, in fact, a template or temploid.
1377 * gcc/cp/pt.c (check_explicit_specialization): Do not allow
1378 explicit specializations to be declared 'concept', and do not allow
1379 an explicit specialization of a concept.
1380 * gcc/cp/decl.c (grokfndecl): Propagate the concept flag to
1381 check_explicit_specialization.
1383 2013-10-22 Andrew Sutton <andrew.n.sutton@gmail.com>
1385 * gcc/c-family/c-common.c (cxx_dialect): Make the default
1387 * gcc/cp/constraint.cc (check_constrained_friend): Don't assert
1390 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1392 * gcc/cp/logic.cc (left_requires), (decompose_left): Add
1393 decomposition rules for requires expressions.
1394 (subsumes_requires), (subsumes_prop): Add subsumption rules for
1395 requires expressions.
1396 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failed conversion
1399 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1401 * gcc/cp/constraint.cc (finish_concept_name): Allow functions with
1402 the same name as concepts to resolve as call expressions in the
1405 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1407 * gcc/cp/constraint.cc (conjoin_requiremens): New.
1408 (resolve_constraint_check): Filter non-concept candidates before
1409 coercing arguments. Perform deduction in a template-decl processing
1410 context to prevent errors during diagnosis.
1411 (finish_concept_name), (finish_shorthand_requirement),
1412 (get_shorthand_requirements): New.
1413 * gcc/cp/pt.c (template_parm_to_arg): Make non-static.
1414 (process_templat_parm): Build shorthand requirements from the
1415 parameter description.
1416 (end_templat_parm_list): New.
1417 (convert_placeholder_argument): New.
1418 (convert_template_argument): Match placeholder arguments against
1419 any template parameter.
1420 (tsubst_pack_conjuction): New.
1421 (tsubst_expr): Expand a pack as a conjunction.
1422 (type_dependent_expression_p): Placeholders are always type
1424 * gcc/cp/parser.c (cp_is_constrained_parameter),
1425 (cp_finish_template_type_parm), (cp_finish_template_template_parm)
1426 (cp_finish_non_type_template_parm), (cp_finish_constrined_parameter):
1428 (cp_parser_template_parameter): Handle constrained parameters.
1429 (cp_parser_nonclass_name): An identifier naming an overload set
1430 may declare a constrained parameter.
1431 (cp_parser_type_parameter), (cp_parser_template_declaration_after_exp):
1432 Get shorthand requirements from the tmeplate parameter list.
1433 * gcc/cp/cp-tree.h (TEMPLATE_PARM_CONSTRAINTS): New.
1435 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1437 * gcc/cp/cp-tree.h (check_constrained_friend): Take requirements as
1439 * gcc/cp/constraints.cc (check_constrained_friend): Do not diagnose
1440 errors in unconstrained friend declarations.
1441 * gcc/cp/parser.cc (cp_parser_member_declaration): Pass current
1442 requirements to check_constrained_friend.
1444 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1446 * gcc/cp/parser.c (cp_parser_member_declaration): Check that
1447 a constrained friend definition is valid.
1448 * gcc/cp/decl.c (grokfndecl): Disallow constrained friend template
1450 * gcc/cp/constraints.cc (check_constrained_friend): New.
1451 * gcc/cp/typeck.c (cp_build_function_call_vec): Diagnose constraints
1452 in the presence of the failure of a single candidate.
1453 * gcc/cp/cp-tree.h (check_constrained_friend): New.
1454 * gcc/cp/call.c (is_non_template_member_fn): Make inline.
1455 (is_non_template_friend), (is_constrainable_non_template_fn): New.
1456 (add_function_candidate): Predicate check on
1457 is_constrainable_non_template_fn.
1459 2013-09-10 Andrew Sutton <andrew.n.sutton@gmail.com>
1461 * gcc/cp/cp-tree.h (TEMPLATE_PARMS_CONSTRAINTS): New.
1462 * gcc/cp/parser.c (cp_parser_template_declaration_after_export),
1463 (cp_parser_type_parameter): Use TEMPLATE_PARMS_CONSTRAINTS.
1464 * gcc/cp/semantics.c (fixup_template_scope): Use
1465 TEMPLATE_PARMS_CONSTRAINTS.
1467 2013-09-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1469 * gcc/cp/cxx-pretty-print.c (pp_cxx_compound_requirement),
1470 (pp_cxx_type_requirement), (pp_cxx_validtype_expr): Use
1471 pp->type_id() instead of pp_cxx_type_id().
1473 2013-09-09 Andrew Sutton <andrew.n.sutton@gmail.com>
1475 * gcc/cp/pt.c (get_class_bindings): Pass the partial specialization
1476 for constraint evaluation. Evaluate constraints, resulting in
1477 deduction failure on error.
1478 (get_specializaing_template_decl), (get_specialization_constraints),
1479 (maybe_new_partial_specialization): New.
1480 (maybe_process_partial_specialization): Allow the creation of
1481 new types for constrained partial specializations.
1482 (process_partial_specialization): Modify the canonical type
1483 of constrained partial specializations.
1484 (instantiate_class_template_1): Do not explicitly check constraints
1485 during class template instantiation.
1486 (tsubst_decl): Instantiate the constraints of template declarations.
1487 (more_specialized_class): Pass specializations to get_class_bindings().
1488 Compare specialization constraints if the types are equivalent.
1489 (most_specialized_class): Pass specialization to get_class_bndings().
1490 * gcc/cp/decl2.c (check_class_fn): Get the decl's requirements from
1491 either the current template reqs or from the template parameters.
1492 Allow overloading of constrained out-of-class member definitions.
1493 * gcc/cp/semantics.c (fixup_template_type): New. Match the template
1494 scope to a specialization with appropriate constraints.
1495 (finish_template_type): Fix template type when entering scope.
1496 * gcc/cp/parser.c (cp_parser_parse_type_parameter): Attach
1497 requirements to the current template parameter list.
1498 (cp_parser_init_declarator): Parse requires clauses for out-of-class
1499 member definitions. Be sure to restore current constraints before
1500 exiting the function.
1501 (cp_parser_member_declarator): Restore the previous requirements in
1502 an early-exit branch.
1503 (cp_parser_late_parsing_for_member): Restore constraints after
1504 maybe_end_member_template_processing().
1505 (cp_parser_template_declaration_after_exp): Attach constraints to
1506 the current template parameters.
1507 * gcc/cp/constraint.cc (reduce_template_id): Don't crash when
1508 omitting ()'s on constraint calls.
1509 (check_requirements): Don't evaluate dependent arguments.
1510 (check_constraints): Don't try to evaluate when arguments are
1512 (equivalent_constraints): Optimize the case when a and b are the
1515 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1517 * gcc/cp/semantics.c (trait_expr_value): Evaluate __is_same_as.
1518 (finish_trait_expr): Check __is_same_as and __is_convertible_to.
1519 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failures in
1521 * gcc/cp/parser.c (cp_parser_primary_expression),
1522 (cp_parser_trait_expr): Parse __is_same_as.
1523 * gcc/cp/cp-tree.h (cp_trait_kind): Add CPTK_IS_SAME_AS.
1524 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Pretty print
1527 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1529 * gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
1530 requires expr parameter list.
1532 2013-07-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1534 * gcc/cp/parser.c (cp_parser_requires_expr): Update parser using new
1535 requires expression nodes. Renamed some grammar productions to better
1536 reflect the representation of the syntax. Create a new scope for
1537 requires parameters.
1538 (cp_parser_nested_requirement): Wrap results in a NESTED_REQ node.
1539 * gcc/cp/semantics.c (xvalue_result_type): New.
1540 (trait_expr_value): Evaluate __is_convertible_to.
1541 (finish_requires_expr): Implemented, along with other functions to
1542 construct and evaluate nodes for template constraints.
1543 (potential_constant_expression_1): Handle requires expressions.
1544 (finish_template_requirements), (finish_requires_expr), etc:
1545 Move to constraint.cc.
1546 * gcc/cp/cp-tree.def: (REQUIRES_EXPR), (EXPR_REQ), (TYPE_REQ),
1547 (NESTED_REQ), (VALIDEXPR_EXPR), (VALIDTYPE_EXPR), (CONSTEXPR_EXPR):
1549 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Make new nodes typed.
1550 * gcc/cp/cp-tree.h (finish_expr_requirement),
1551 (finish_type_requirement), (finish_nested_requirement),
1552 (finish_validexpr_expr), (finish_validtype_expr),
1553 (finish_constexpr_expr): New.
1554 * gcc/cp/pt.c (convert_nontype_argument): Use can_convert_standard.
1555 (retrieve_local_specialization), (register_local_specialization),
1556 (extract_fnparm_pack): Make non-static.
1557 (tsubst_expr): Substitution rules for requires expressions.
1558 (instantiate_requirements): Move to constraints.cc
1559 (tsubst_constraint): Remove.
1560 * gcc/cp/call.c (can_convert): Allow user-defined conversions.
1561 (can_convert_standard): New.
1562 * gcc/cp/cvt.c (convert_to_reference): Use can_convert_standard.
1563 * gcc/cp/search.c (check_final_overrider): Use can_cnvert_standard.
1564 * gcc/cp/typeck.c (build_static_cast_1): Use can_convert_standard.
1565 * gcc/cp/error.c (dump_expr): Pretty print new nodes.
1566 * gcc/cp/cxx-pretty-print.c (pp_cxx_primary_expression): Pretty
1567 print new expr/req nodes.
1568 (pp_cxx_requires_expr): New along with related functions for
1569 pretty printing requirements.
1570 (pp_cxx_parameter_declaration_clause): Accommodate "raw" parameter
1571 lists in addition to function decls.
1572 (pp_cxx_requirement_parameter_list): Unified with parameter decl clause.
1573 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_expr): New along with
1574 related functions for pretty printing requirements.
1575 * gcc/cp/logic.cc: Move header comments to top of file.
1576 * gcc/cp/constraint.cc (reduce_requirements): Handle requires
1578 (diagnose_constraints): Rename and handle requires expressions.
1580 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1582 * gcc/cp/error.c (cp_printer): Fix unnecessary whitespace change.
1583 * gcc/cp/constraint.cc (diagnose_node): Don't fail diagnosing
1586 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1588 * gcc/cp/class.c (are_constrained_member_overloads): Fix doc typos.
1590 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1592 * gcc/cp/parser.c (cp_parser_init_declarator): Parse template
1593 requirements for out-of-class member definitions.
1594 * gcc/cp/decl2.c (check_classfn): Include match out-of-class
1595 definitions using constraints.
1596 * gcc/cp/constraint.cc (equivalently_constrained). Use get_constraints.
1597 (more_constrained). Use get_constraints.
1599 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1601 * gcc/cp/cp-tree.h (tree_template_info). Remove constraint from
1603 (check_template_info): Removed (unused).
1604 (TI_CONSTRAINT): Removed (no longer needed) along with related macros.
1605 (DECL_CONSTRAINTS): New. Get constraints from DECL_SIZE_UNIT for
1607 (build_template_info): Removed overload taking constraints.
1608 (get_constraints): Removed (no longer needed).
1609 * gcc/cp/class.c (are_constrained_member_overlaods): Allow constrained
1610 member function templates to be differentiated as overloads.
1611 * gcc/cp/decl.c (decls_match): Only compare constraints on
1613 (grokfndecl): Don't pass constraints to build_template_info.
1614 * gcc/cp/tree.c (bind_template_template_parm): Don't pass constraints
1615 to build_template_info.
1616 * gcc/cp/pt.c (build_template_info): Removed overload taking
1618 (check_explicit_specialization): Don't build new constraints for
1620 (build_template_decl): Pass constraints. Update docs.
1621 (process_partial_specialization): Stub out support for constrained
1622 partial specialiations.
1623 (push_template_decl_real): Build template decls with current template
1624 reqs. Don't pass constraints to build_template_info.
1625 (add_inherited_template_parms): Build new constraints from inherited
1626 template constructors.
1627 (redeclare_class_template): Update to new constraint interface.
1628 (is_compatible_template_arg): Update to new constraint interface.
1629 (lookup_template_class_1): Don't build new constraints or pass them to
1630 build_template_info.
1631 (instantiate_class_template_1): Update to new constraints interface.
1632 (tsubst_decl): Don't build new constraints or pass them to
1633 build_template_info. For function templates, explicitly instantiate
1634 new constraints for member functions of class templates.
1635 * gcc/cp/semantics.c: Associate constraints with template template
1636 parms directly, not through template info.
1637 * gcc/cp/constraint.cc (get_constraints): Simplified to use new constraints
1639 (check_constraints): Update to use new constraints interface.
1640 (equivalently_constrained): Update to use new constraints interface.
1641 (more_constrained): Update to use new constraints interface.
1642 * gcc/cp/parser.cpp (cp_parser_late_parsing_for_member): Update to use
1643 new constraints interface.
1644 * gcc/cp/call.c (is_non_template_member_fn): New.
1645 (add_function_candidate): Only check constraints for non-template member
1648 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1650 * gcc/cp/parser.c (cp_parser_requires_clause): Pulled out of
1651 cp_parser_requires_clause_opt for reuse in the requires expr parser.
1652 (cp_parser_requires_expression): New, along with a family of
1653 sub-expression parsers for the new feature.
1654 * gcc/cp/semantics.c (finish_requires_expr): Stub.
1655 (finish_syntax_requirement): Stub.
1656 (finish_type_requirement): Stub.
1657 (finish_constexpr_requirement): Stub.
1658 (finish_noexcept_requirement): Stub.
1659 (finish_requires_expr): Stub.
1660 * gcc/cp/cp-tree.h: (finish_requires_expr): New.
1661 (finish_syntax_requirement): New.
1662 (finsih_type_requirement): New.
1663 (finish_constexpr_requirement): New.
1664 (finish_noexcept_requirement): New.
1666 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1668 * gcc/cp/error.c (subst_to_string): Allow this to be called explicitly
1669 passing template parameters in the TREE_TYPE and with a null
1671 * constraint.cc (check_requirements): New overload taking template
1673 (check_constraints.cc): Move instantiation and checking into the
1674 new check_requirements overload.
1675 (diagnose_requirements): New family of functions for diagnosing
1676 constraint failures.
1678 2013-06-18 Andrew Sutton <andrew.n.sutton@gmail.com>
1680 * gcc/cp/class.c (are_constrained_member_overloads): New.
1681 (add_method): Allow overloading of constrained member functions.
1682 * gcc/cp/call.c (rejection_reason_code): New rr_constraint_failure.
1683 (template_constraint_failure): New.
1684 (add_function_candidate): Check for viability as a precondition to use.
1685 (add_template_candidate_real): Integrate constraint diagnostics.
1686 Provide constraint info for new template instantiations.
1687 (print_z_candidate): Emit diagnostics for constraint failures.
1688 (template_decl_for_candidate): New.
1689 (joust): Allow non-member templates of class templates to be evaluated
1690 in more_specialized_fn if they are constrained.
1691 * gcc/cp/ptree.c (cxx_print_xnode): Dump constraint info.
1692 * gcc/cp/semantics.c (finish_template_template_parm): Build template
1693 info for template template parameters.
1694 (is_unary_trait): New.
1695 (is_binary_trait): New.
1696 (finish_trait_expr): Check for binary traits using new function.
1697 * gcc/cp/constraint.cc (join_requirements): New
1698 (conjoin_requirements): Join expressions correctly. Fixed docs.
1699 (disjoin_requirements): Removed.
1700 (is_constriant): Removed.
1701 (resolve_constraint_check): New. Replaces previous get_constraint
1702 check and related functions.
1703 (get_constraints): New, along with helper functions.
1704 (suppress_template_processing): New.
1705 (check_template_constraints): New, along with helper functions.
1706 (equivalent_constraints): New.
1707 (equivalently_constrained): New.
1708 (more_constraints): New.
1709 (more_constrianed): New.
1710 (diagnose_constraint_failure): New.
1711 * gcc/cp/decl.c (decls_match): Check for constraint equivalence if
1712 the types are the same.
1713 (check_concept_refinement): New.
1714 (are_constrained_overloads): New.
1715 (duplicate_decls): Handle constraints for ambigous declarations. Check
1716 and diagnose concept refinement.
1717 (check_concept_fn): Don't fail completely just because the concept
1718 isn't defined correctly. Allow analysis to continue as if declared
1719 constexpr. Concepts must return bool.
1720 * gcc/cp/tree.c (bind_template_template_parm): Provide empty
1721 constraints for bound template template parameters.
1722 * gcc/cp/logic.cc: Rewrite of proof state and related structures and
1723 decomposition logic. Removed right-decomposition logic, but retained
1724 right-logical rules.
1725 (match_terms): Renamed from entails.
1726 (subsumes_prop): Cleanup, added specific handlers for and/or cases.
1727 (subsumes_constraints): Update from interface change.
1728 * gcc/cp/cp-tree.h (check_constraint_info): Renamed and applied
1730 (check_template_info): Renamed and applied interface change.
1731 (cp_unevaluated): New
1732 (local_specialization_stack): New.
1733 (coerce_template_parms): New.
1734 (is_unary_trait): New.
1735 (is_binary_trait): New.
1736 (get_constraints): New.
1737 (check_constraints): New.
1738 (check_template_constraints): New.
1739 (subst_template_constraints): New.
1740 (equivalent_constraints): New.
1741 (equivalently_constrained): New.
1742 (more_constraints): New.
1743 (more_constrained): New.
1744 (diagnose_constraints_failure): New.
1745 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Print the
1746 template requirements.
1747 * gcc/cp/pt.c (local_specialization_stack): New.
1748 (build_template_info): Refactor into 3-argument version and
1749 incorporate template requirements.
1750 (check_explicit_specialization): Instantiate requirements for
1752 (push_template_decl_real): Include constraints in template info.
1753 (redeclare_class_template): Diagnose redeclaration with different
1755 (is_compatible_template_arg): New.
1756 (convert_template_argument): Check constraints on template template
1757 arguments and diagnose errors.
1758 (lookup_template_class_1): Check constraints on alias templates.
1759 Keep constraints with instantiated types.
1760 (instantiate_class_template_1): Check constraints on class templates.
1761 (tsubst_decl): Instantiate and keep constraints with template info.
1762 Also, allow dependent pack arguments to produce neww parameter
1763 packs when instantiated.
1764 (coerce_template_parms): New overload.
1765 (tsubst_copy): Handle REAL_TYPE and BOOLEAN_TYPE.
1766 (tsubst_copy_and_build): PARM_DECLs can be instantiated as pack
1767 expansions (used with requires expression).
1768 (fn_type_unification): Check constraints for function templates.
1769 (more_specialized_fn): Determine which candidate is more constrained.
1770 (substitute_template_parameters): Removed.
1771 (tsubst_constraint): New.
1772 (substitute_requirements): New.
1773 * gcc/cp/parser.c: (cp_parser_optional) Removed along with helper
1775 (cp_unevaluated): New.
1776 (cp_parser_type_parameter): Check for requires kw explicitly, and
1777 save/clear template requirements before parsing the requires clause.
1778 (cp_parser_requires_clause): Removed.
1779 (cp_parser_template_declaration_after_exp): Check for requires kw
1781 * gcc/system.h (cstdlib): Removed include.
1782 * gcc/c-family/c-common.h (D_CXX_CONCEPTS): New flag for disabling
1784 * gcc/c-family/c.opt (flag_concepts): Remove redundant declaration.
1785 * gcc/c-family/c-common.c (c_common_r): Concept-specific keywords
1786 are only enabled when concepts are enabled.
1788 2013-06-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1790 * gcc/system.h (cstdlib): Include <cstdlib> to avoid poisoned
1792 * gcc/c-family/common.c (c_common_r): Added __is_same_as intrinsic,
1793 removed previous, unused intrinsics.
1794 * gcc/c-family/common.h (rid): Added RID_IS_SAME_AS.
1795 * gcc/cp/parser.c (take): New.
1796 (cp_requires_clause): New.
1797 (cp_requires_clause_opt): New.
1799 (cp_parser_optional_if_token): New.
1800 (cp_parser_optional_if_not_token): New.
1801 (cp_parser_optional_if_keyword): New.
1802 (cp_parser_decl_specifier_seq): Parse 'concept' as a declspec.
1803 (cp_parser_type_parameter): Parse constrained template template parms.
1804 (cp_parser_member_specification_opt): Parse member constraints after
1805 the declaration, not before.
1806 (cp_parser_template_declaration_after_exp): Rewrote parsing for
1807 template requirements
1808 (cp_parser_late_parsing_for_member): Re-push the current template
1809 requirements when late-parsing member definitions.
1810 * gcc/cp/decl.c (check_concept_fn): New.
1811 (grokfndecl): Semantics for concept declspec.
1812 (grokdeclarator): Semantics for concept declspec.
1813 (xref_tag_1): Update to new interface.
1814 * gcc/cp/constraint.cc (make_constraints): New.
1815 * gcc/cp/cp-objcp-common.c (cp_tree_size): Add case for constraint_info.
1816 * gcc/cp/cp-tree.h (require): New.
1817 (tree_template_info): Add a field for constraint info.
1818 (tree_constraint_info): New.
1819 (constraint_info_p): New.
1820 (template_info_p): New.
1822 (CI_REQUIREMENTS): New.
1823 (CI_ASSUMPTIONS): New.
1824 (TI_CONSTRAINT): New.
1826 (TI_REQUIREMENTS): New.
1827 (TI_ASSUMPTIONS): New.
1828 (DECL_TEMPLATE_CONSTRAINT): New.
1829 (CLASSTYPE_TEMPLATE_CONSTRAINT): New.
1830 (ENUM_TEMPLATE_CONSTRAINT): New.
1831 (TEMPLATE_TEMPLATE_PARM_TEMPLATE_CONSTRAINT): New.
1832 (TYPE_TEMPLATE_CONSTRAINT): New.
1833 (cp_tree_node_structure_enum): Added entry for constraint info.
1834 (lang_tree_node): Added entry for constraint info.
1835 (lang_decl_base): Added bit for concept declarations.
1836 (DECL_DECLARED_CONCEPT_P): New.
1837 (cp_decl_spec): Added ds_concept declaration specifier.
1838 * gcc/cp/Make-lang.in (logic.o): New target.
1839 * gcc/cp/semantics.c (finish_template_requirements): Rewrite.
1840 * gcc/cp/logic.cc: New
1841 * gcc/cp-tree.def (CONSTRAINT_INFO): New node.
1842 * gcc/cp/pt.c (current_template_args): Make non-static.
1843 (redeclare_class_template): Take constraints as a 3rd argument
1845 2013-04-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1847 * gcc/cp/Make-lang.in: Add constraints.o target.
1848 * gcc/cp/cp-tree.h (substitute_template_parameters): Declare.
1849 (instantiate_requirements): Declare.
1850 (conjoin_requirements): Declare.
1851 (disjoin_requirements): Declare.
1852 (reduce_requirements): Declare.
1853 * gcc/cp/pt.c (substitute_template_parameters): Define.
1854 (instantiate_requirements): Define.
1855 * gcc/cp/pt.c (finish_template_requirements): Call
1856 reduce_requirements to get constraints.
1857 * gcc/cp/parser.c (cp_parser_type_parameter): Restore saved
1858 constraints after parsing template template parameter decl.
1859 * gcc/cp/constraints.cc: New.
1861 2013-03-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1863 * gcc/cp/Make-lang.in: Add constraint.c
1864 * gcc/cp/constraint.c: New
1865 (conjoin_requirements): New
1866 (disjoin_requirements): New
1867 (requirement_reduction): New class
1868 (reduce_requirements): New
1869 * gcc/cp/cp-tree.h (reduce_requrements): New
1870 (conjoin_requirements): New
1871 (disjoin_requirements): New
1872 * gcc/cp/cp-tree.h (finish_template_template_parm) Comments.
1873 * gcc/cp/semantics.c (finish_template_requirements) Start
1874 working with requirements.
1877 2013-03-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1879 * gcc/cp/cp-tree.h (saved_scope): Add template requirements.
1880 (finish_template_requirements): Declare
1881 * gcc/cp/parser.c (cp_parser_template_requirement_opt): Declare.
1882 (cp_parser_template_declaration): Document grammar extensions.
1883 (cp_parser_type_parameter): Parse requirements for template
1884 template parameters.
1885 (cp_parser_member_declaration): Parse requirements for
1886 members of class templates.
1887 (cp_parser_template_requirement_opt): Define.
1888 (cp_parser_template_declaration_after_exp): Parse requirements
1889 for template declarations.
1890 * gcc/cp/semantics.c (finish_template_requirements): Define.
1891 * gcc/cp/lex.c (cxx_init): Enable concepts by default.
1893 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
1895 * lex.c (flag_concepts): Revert left over declaration.
1897 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
1899 * gcc/c-family/c-common.c (cxx_dialect): Set C++11 as default.
1900 * gcc/c-family/c.opt(flag_concepts): Add.
1901 * gcc/cp/lex.c (flag_concepts): New. Enabled concept support by
1904 2013-02-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1906 * gcc/c-family/c-common.h (rid): New resreserved words for concepts.
1907 * gcc/c-family/c-common.c (c_common_reswords): Definitions thereof.
1908 * gcc/doc/extend.texi (write_symbol): Initial concept docs.