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