1 2015-04-02 Andrew Sutton <andrew.n.sutton@gmail.com>
4 * gcc/cp/except.c (check_noexcept_r): Check the function type
5 and not the return type for (TYPE_NOTHROW_P).
6 * gcc/cp/parser.c (cp_parser_check_for_invalid_template_id): Remove
8 * gcc/testsuite/g++.dg/concepts/pr65634: New.
10 2015-04-02 Andrew Sutton <andrew.n.sutton@gmail.com>
12 Fixing constraint processing bugs.
13 * gcc/cp/constraint.cc (check_logical_expr): Use build_x_binary_op
14 so that the c-common doesn't try to fold requires-expressions.
15 * gcc/cp/constexpr.c (cxx_eval_constant_expression): The value
16 of a requires clause is true iff its constraints are satisfied.
17 This lets us check negated requires-expressions.
18 * gcc/testsuite/g++.dg/concepts/req4.C: Update diagnostics
19 * gcc/testsuite/g++.dg/concepts/req5.C: Update diagnostics
20 * gcc/testsuite/g++.dg/concepts/req11.C: New.
22 2015-03-27 Andrew Sutton <andrew.n.sutton@gmail.com>
24 Trying again with PR65575.
25 * gcc/cp/parser.c (cp_parser_declarator): Search through
26 declarator structure for likely matches for function
28 * gcc/testsuite/g++.dg/concepts/pr65575.C: Update with
31 2015-03-25 Andrew Sutton <andrew.n.sutton@gmail.com>
34 * gcc/cp/parser.c (cp_parser_declarator): Don't emit errors
35 when a trailing requires-clause follows a non-function
37 * gcc/testsuite/g++.dg/concepts/pr65575.C: New.
39 2015-03-25 Andrew Sutton <andrew.n.sutton@gmail.com>
41 Fix scope-squashing error in PR65552.
42 * gcc/cp/parser.C (cp_parser_type_requirement): Save and
43 restore scopes around optional nested name specifier parse.
44 * gcc/testsuite/g++.dg/concepts/pr65552.C: New.
46 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
48 Fix bug in disjunction processing and fix the pretty
49 printing for __is_same_as trait correct.
50 * gcc/cp/constraint.cc (check_disjunction): Don't return
51 false if the first condition fails and the second succeeds.
52 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expr): Print the
53 second argument for __is_same_as.
55 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
57 Make implicit conversion constraints handle usual
58 conversions, not just implicit conversions.
59 * gcc/cp/constraint.cc (check_implicit_conversion_constraint):
60 Use perform_direct_initialization_if_possible to test for
61 converibility instead of can_convert_arg.
62 * gcc/testsuite/g++.dg/concepts/req10.C: New.
64 2015-03-24 Andrew Sutton <andrew.n.sutton@gmail.com>
66 Suppress errors regarding deleted functions when
68 * gcc/cp/pt.c (tsubst_baselink): Pass complain flags to
70 * gcc/testsuite/g++.dg/concepts/expression3.C: New.
72 2015-03-22 Andrew Sutton <andrew.n.sutton@gmail.com>
74 Fix regression related to variadic templates, bugs in
75 the handling of access checking, and in the logic solver.
76 * gcc/cp/constraint.cc (declare_constraint_vars): Mark
78 (deferring_access_check_sentinel): Make this a local class
79 of check_expression_constraint.
80 (check_type_constraint): Don't defer access checks. Instead
81 pop deferred access checks if they fail.
82 (finish_requires_expr): Mark constraint variables.
83 * gcc/cp/cp-tree.h (CONSTRAINT_VAR_P): Indicates if a
84 parameter is a constraint variable.
85 * gcc/cp/pt.c (pending_expansion_p): New. Helps determine
86 if a parameter will be expanded during substitution.
87 (tsubst_pack_expansion): For certain expressions pending
88 expansion, do that here.
89 (tsubst_decl): Remove dead code.
90 (tsubst_copy_and_build): Don't add arguments that are
91 pending expansion. Also, don't build expansion when the
92 type is dependent. This was causing a regression in
94 * gcc/cp/logic.cc (proof_state::branch): Don't rely on
95 order of operations. This crashed when built with Clang.
96 * gcc/testsuite/g++.dg/concepts/expression2.C: Update to
99 2015-03-21 Andrew Sutton <andrew.n.sutton@gmail.com>
101 Completely suppress access violations occurring from
103 * gcc/cp/constraint.cc (deferring_access_check_sentinel): New helper
104 class for managing deferred access checks.
105 (check_expression_constraint): Explicitly defer constraint checks.
106 (check_type_constraint): Explicitly defer constraint checks.
107 * gcc/testsuite/g++.dg/concepts/expression3.C: New.
109 2015-03-21 Andrew Sutton <andrew.n.sutton@gmail.com>
111 Fail constraints due to access violations in non-SFINAE
113 gcc/cp/constraint.cc (check_expression_constraint,
114 check_type_constraint): Check for access violations.
115 gcc/cp/pt.c (tsubst_decl): Make sure that template
116 info exists before dereferencing it.
117 * gcc/testsuite/g++.dg/concepts/expression2.C: New.
119 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
121 Fix grammar error type requirements and improve diagnostics
122 for mis-defined function concepts and errors involving pack
124 * gcc/cp/pt.c (determine_specialization). Remove dead code.
125 (lookup_template_class_1): Return an error if constraints
127 * gcc/cp/constraint.cc (lift_function_definition): Don't
128 re-check for empty/erroneous concept definitions.
129 (lift_pack_expansion): Removed. Don't inline patterns so
130 that we can preserve the syntax beneath them.
131 (lift_expression): Don't do anything with pack expansions.
132 (check_function_concept): Specifically check for empty
134 (diagnose_pack_expansion): Diagnose errors in expansions
135 more thoughtfully by determining which arguments are failing
136 their expanded requirements.
137 gcc/cp/parser.c (cp_parser_type_requirement): Accept an
138 optional template keyword before a template-id and
139 parse that as a special case of required type name.
140 gcc/testsuite/g++.dg/concepts/template-parm11.C: Update test
141 for fixed grammar, diagnostics.
143 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
145 Ensure that empty expansions are satisfied.
146 * gcc/cp/constraint.cc (check_pack_expansion): Empty expansions
148 * gcc/testsuite/g++.dg/concepts/template-parm11.C: New.
150 2015-03-20 Andrew Sutton <andrew.n.sutton@gmail.com>
152 Fix regression in variadic constraint processing.
153 * gcc/cp/pt.c (tsubst_pack_expansion): Expose declaration.
154 * gcc/cp/constraint.cc: Rename lift_constraints to
155 lift_expression to better reflect what it does.
156 (lift_pack_expansion): New. Handles naked pack expansions
158 (check_pack_expansion): Special handling for checking naked
159 pack expansions in constraints. This eventually be replaced
160 by similar logic for fold expressions.
161 (check_predicate_constraint): Handle pack expansions.
162 * gcc/cp/cp-tree.h (tsubst_pack_expansion): Make this avaialble
165 2015-03-18 Andrew Sutton <andrew.n.sutton@gmail.com>
167 Update variable concept processing to account for changes
168 in variable template syntax.
169 * gcc/cp/constraint.cc (valid_predicate_p): Remove because of
171 (make_predicate_constraint): Likewise.
172 (lift_function_call): Check for use of variables in function
173 calls in constraints.
174 (lift_call_expression): Renamed from lift_call. Specifically
175 check function calls before rewriting the node.
176 (lift_variable_concept). Renamed from lift_var. Remove redundant
178 (lift_variable). New. Accommodates new processing rules for
180 (lift_constraints). Add variable decls to the switch.
181 * gcc/cp/pt.c (finish_variable_template): Don't evaluate
182 for dependent template arguments.
183 (remove_constraints): Remove debugging code.
184 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: Separate out
185 failing test into equiv2.C.
186 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: Update error
188 * gcc/testsuite/g++.dg/concepts/equiv2.C: New.
190 2015-03-18 Andrew Sutton <andrew.n.sutton@gmail.com>
192 Addressing regressions after merge.
193 * gcc/cp/parser.c (cp_parser_template_declaration_after_export):
194 Revert implementation of concept introductions. It was causing
196 * gcc/testsuite/g++.dg/concepts/friend1.C: Update test to account
197 for apparent fix (?) to lookup rules involving friends.
199 2015-03-03 Andrew Sutton <andrew.n.sutton@gmail.com>
201 Rewrite to use new constraint model.
202 * gcc/cp/call.c (add_function_candidate): Use new constraint
204 (build_new_function_call): Evaluate concepts when selected
205 by overload resolution.
206 * gcc/cp/class.c (resolve_address_of_overloaded_function):
207 Use new constraint interface.
208 * gcc/cp/constexpr.c (cxx_eval_constant_expression): Don't
209 try to constexpr evaluate a requires-expression.
210 (potential_constant_expression_1): Stop using old
211 requires/constraint features.
212 gcc/cp/constraint.cc: Much rewriting, reorganization, refactoring
213 to support new constraint/requirement terms.
214 (lift_function_definition): New. Factor lifting code out of
215 lift_call for reuse in evaluate_function_concept.
216 (lift_variable_intializer): New. Factor lifting code out of
217 lift_var for reuse in evaluate_variable_concept.
218 (lift_template_id): Restore checking code for mis-written
220 (lift_requires_expr): Handle these separately.
221 (xform_*_requirement): New. Transform requires-expressions
223 (get/set/remove_constraints, decl_constraints): Move to
224 pt.c to allow for garbage collection.
225 (processing_constraint): Kill this global.
226 (diagnose_*): Update diagnostics to use the new constraint
228 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Remove typing
230 * gcc/cp/cp-tree.def: Add new nodes for requirements and
231 constraints. Remove previous constraint/req nodes.
232 gcc/cp/cp-tree.h (COMPOUND_REQ_NOEXCEPT_P): New.
233 (ICONV_CONSTR_EXPR, ICONV_CONSTR_TYPE): Fix operands.
234 (constraint_p, make_predicate_constraint_p, valid_constraints_p): New.
235 (misc): Remove unused declarations.
236 gcc/cp/cxx-pretty-print.c: Reorganize/rewrite for new constraint
238 (primary_expression, expression): Remove unused nodes, add options
240 gcc/cp/cxx-pretty-print.h: Declare new functions for pretty
242 gcc/cp/decl.c (duplicate_decls): Only reclaim when flag_concepts
244 (grokfndecl): Associate predicate constraints.
245 gcc/cp/decl2.c (mark_used): Don't instantiate concepts.
246 gcc/cp/error.c (dump_expr): Handle new constraints.
247 gcc/cp/method.c (implicitly_declare_fn): Use new constraint
249 gcc/cp/parser.c (make_call_declarator): Pass a requires-clause for
251 (cp_parser_type_name): Take a flag to indicate the presence of
252 a pre-parsed 'typename'.
253 (cp_parser_requires_expression): Move sentinel into function.
254 (cp_parser_type_requirement): Parse type requirements in accordance
256 (cp_parser_compound_requirement): Parse compound requirements in
257 accordance with Concepts TS. Remove constexpr requirements.
258 (cp_parser_template_declaration_after_export): Associate
259 predicate constraints.
260 gcc/cp/pt.c (get_template_for_ordering): New. Extract a template
261 decl from a list of candidates.
262 (lookup_template_class_1): Use new constraint interface.
263 (tsubst_pack_conjunction): Build an expression, not constraints.
264 (tsubst_decl): Only associate constraints when substituting
266 (tsubst): Kill subst rules for old nodes.
267 (most_specialized_partial_spec): Save candidates correctly
268 in the presence of constraints.
269 (always_instantiate_p): Never always instantiate a concept.
270 (type_dependent_expression_p): Requires expressions have type bool.
271 (decl_constraints): Moved from constraint.cc, use hash_table
273 gcc/cp/semantics.c (finish_call_expr): Remove constraints from
274 functions, not overload sets.
275 (finish_template_variable): Evaluate variable concepts by
276 determining satisfaction.
277 gcc/cp/typeck.c (cp_build_function_call_vec): Use new concept
279 gcc/cp/testsuite/g++.dg/concepts/*: Update tests to match syntax,
281 gcc/cp/testsuite/g++.dg/concepts/req1.C: Test requires-expression
284 2015-02-25 Braden Obrzut <admin@maniacsvault.net>
286 * gcc/cp/constraint.cc (lift_operands): New.
287 (lift_call): Lift operands on function calls and don't use
288 tsubst_constraint_expr.
289 (lift_var): Don't use tsubst_constraint_expr.
290 (lift_constraints): Use the returned number of operands for most nodes
291 and also lift from TREE_LISTs.
293 2015-02-17 Braden Obrzut <admin@maniacsvault.net>
295 * gcc/cp/constraint.cc (lift_call): Converted from normalize_call.
296 (lift_var): Converted from normalize_var.
297 (lift_template_id): Converted from normalize_template_id.
298 (lift_constraints): Implemented.
300 2015-02-16 Andrew Sutton <andrew.n.sutton@gmail.com>
302 * gcc/cp/cp-tree.h: (EXPR_CONSTR_EXPR, TYPE_CONSTR_TYPE): Fix
303 typos in macro names.
304 * gcc/cp/constraint.cc: (check_constraint*): New. Rewrite the
305 constraint checking implementation so that it matches the
306 wording and rules in n4377.
308 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
310 * gcc/cp/logic.cc: Rewrite to use new constraint model and
312 * gcc/cp/constraint.cc: Documentation and organization.
314 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
316 * gcc/cp/cp-tree.h (is_constraint): Make static.
318 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
320 Rewrite normalization in terms of constraints.
321 * gcc/cp/cp-tree.h (is_constraint): New.
322 * gcc/cp/constraint.cc (normalize_*): Rewrite the previous normalization
323 model so that it conforms with the specification. Normalization applies
324 to constraints. Transformation of expressions into constraints now
325 happens in two phases: lifting concept definitions, and the actual
327 (tranform_expression, xform_*): New. Define transformation of
328 expressions into constraints.
329 (lift_constraints): New. Stubbed out inlining function.
331 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
333 Start refactoring constraints to match the specification.
334 * gcc/cp/cp-tree.def: Add new TREECODEs for constraints.
335 * gcc/cp/cp-tree.h: Add accessor macros for constraint operands.
337 2015-02-05 Braden Obrzut <admin@maniacsvault.net>
339 * gcc/cp/constexpr.c (potential_constant_expression_1): Readded missing
340 cases from previous merge from trunk.
341 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Restored
342 CPTK_IS_CONVERTIBLE_TO for the time being since the constraint code
344 * gcc/cp/semantics.c (finish_trait_expr): Likewise.
345 * gcc/testsuite/g++.dg/concepts/req9.C: New test.
347 2015-02-03 Braden Obrzut <admin@maniacsvault.net>
349 * gcc/cp/class.c (build_clone): Clone constraints.
350 * gcc/cp/constraint.cc (normalize_atom): Update diagnostic.
351 (normalize_constraints): Return error_mark_node if normalization fails.
352 (get_constraints): Access constraints through hash map.
353 (set_constraints): Set constraints through hash map.
354 (remove_constraints): Access constraints through hash map.
355 (associate_classtype_constraints): New.
356 (init_leading_requirements): Removed.
357 (init_trailing_requirements): Removed.
358 (update_leadng_requirements): Removed.
359 (update_trailing_requirements): Removed.
360 (save_leading_constraints): Removed.
361 (save_trailing_constraints): Removed.
362 (finish_template_constraints): Removed.
363 (build_constraints): New. Builds CONSTRAINT_INFO from requirements.
364 (finish_concept_introduction): Check generated parameters for errors.
365 (tsubst_constraint_info): Update implementation.
366 (equivalent_constraints): Check input types.
367 (subsumes_constraints): Update implementation.
368 (at_least_as_constrained): New. Check if a decl's constraints subsumes
370 (diagnose_constraints): Temporarily simplify diagnostics.
371 * gcc/cp/cp-tree.h (tree_constraint_info): Refactor the way constraints
373 (CI_TEMPLATE_REQS): Renamed from CI_LEADING_REQS.
374 (CI_DECLARATOR_REQS): Renamed from CI_TRAILING_REQS.
375 (CI_ASSOCIATED_CONSTRAINTS): New.
376 (CI_NORMALIZED_CONSTRAINTS): New.
377 (CI_ASSOCIATED_REQS): Removed.
378 (saved_scope): Save template requirements.
379 (current_template_reqs): Removed.
380 (lang_decl_min): Replace requires_clause (trailing requirements) with
381 more generic constraint_info.
382 * gcc/cp/cxx-pretty-print.c (cxx_pretty_printer::declarator): Print
384 (pp_cxx_function_definition): Moved requires clause printing to above.
385 (pp_cxx_init_declarator): Likewise.
386 (pp_cxx_template_declaration): Update implementation to get
387 requirements from CONSTRAINT_INFO.
388 * gcc/cp/decl.c (duplicate_decls): Remove constraints before reclaiming
390 (is_class_template_or_specialization): New.
391 (get_leading_constraints): Removed.
392 (adjust_fn_constraints): Removed.
393 (grokfndecl): Update implementation to other changes.
394 (get_trailing_requires_clause): New.
395 (grokdeclarator): Pass trailing requires clause to grokfndecl.
396 (xref_tag_1): Check overload constraints.
397 * gcc/cp/error.c (dump_template_decl): Print requires clause.
398 (dump_function_decl): Update implementation for accessing requirements.
399 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Update
400 CI_ASSOCIATED_REQS usage.
401 * gcc/cp/method.c (implicitly_declare_fn): Copy constraints of
402 inherited constructors.
403 * gcc/cp/parser.c (cp_parser_lambda_expression): Remove now unneeded
404 template requirements saving.
405 (cp_parser_type_parameter): Likewise.
406 (cp_parser_template_argument_list): Unwrap template_template_parms when
407 produced by short hand notation with function concepts.
408 (cp_parser_alias_declaration): Attach constraints to aliases.
409 (cp_manage_requirements): Removed.
410 (cp_parser_trailing_requirements_clause): Renamed from
411 cp_parser_trailing_requirements.
412 (cp_parser_init_declarator): Removed now unneeded requirements saving.
413 (cp_parser_basic_declarator): Separated from cp_parser_declarator.
414 (cp_parser_declarator): Parses trailing requires clause if
415 cp_parser_basic_declarator succeeds.
416 (cp_parser_class_specifier_1): Associate constaints with type.
417 (cp_parser_member_declaration): Remove unneeded template requirement
419 (cp_parser_template_declaration_after_export): Likewise.
420 (cp_parser_single_declaration): Associate constraints.
421 (cp_parser_late_parsing_for_member): Remove unneeded template
423 (synthesize_implicit_template_parm): Likewise.
424 * gcc/cp/pt.c (maybe_new_partial_specialization): Update
426 (process_template_parm): Removed unneeded template requirement saving.
427 (build_template_decl): Handle constraints.
428 (process_partial_specialization): Update constraint access and check
429 that specialization is more specialized.
430 (push_template_decl_real): Update constraint access.
431 (add_inherited_template_parms): Removed constraint handling.
432 (tsubst_pack_conjuction): Update implemenation.
433 (tsubst_decl): Changed constraint propagation.
434 (more_specialized_fn): Update constraint access.
435 (most_specialized_partial_spec): Update constraint access.
436 * gcc/cp/ptree.c (cxx_print_xnode): Update constraint access.
437 * gcc/cp/semantics.c (finish_call_expr): Remove constraints.
438 (finish_template_template_parm): Update constraint access.
439 * gcc/testsuite/g++.dg/concepts/alias4.C: Mark xfail.
440 * gcc/testsuite/g++.dg/concepts/class.C: Check for escape hatch.
441 * gcc/testsuite/g++.dg/concepts/class6.C: Added diagnostic.
442 * gcc/testsuite/g++.dg/concepts/inherit-ctor1.C: Improved test case.
443 * gcc/testsuite/g++.dg/concepts/inherit-ctor2.C: Updated diagnostic.
444 * gcc/testsuite/g++.dg/concepts/inherit-ctor4.C: Updated diagnostic.
445 * gcc/testsuite/g++.dg/concepts/intro4.C: Updated diagnostics.
446 * gcc/testsuite/g++.dg/concepts/req4.C: Updated diagnostic.
447 * gcc/testsuite/g++.dg/concepts/req5.C: Updated diagnostic.
449 2014-12-29 Jason Merrill <jason@redhat.com>
451 * gcc/cp/pt.c (type_dependent_expression_p): Remove obsolete use of
453 (convert_template_argument): Likewise.
455 2014-11-15 Braden Obrzut <admin@maniacsvault.net>
457 * gcc/cp/constraint.cc (resolve_constraint_check): Move definition
459 (normalize_template_id): Use expression location if available when
460 informing about missing parentheses.
461 (build_requires_expr): Added comment.
462 (diagnose_var): Clarified comment.
463 * gcc/cp/decl.c (check_concept_refinement): Remove outdated comment
464 regarding variable concepts.
465 (grokfndecl): Ensure that all concept declarations are definitions.
466 (grokdeclarator): Remove outdated comment regarding variable concepts.
467 * gcc/cp/parser.c (cp_parser_introduction_list): Use vec for temporary
468 list instead of a TREE_LIST.
469 (get_id_declarator): Renamed from cp_get_id_declarator.
470 (get_unqualified_id): Renamed from cp_get_identifier.
471 (is_constrained_parameter): Renamed from cp_is_constrained_parameter.
472 (cp_parser_check_constrained_type_parm): Renamed from
473 cp_check_constrained_type_parm.
474 (cp_parser_constrained_type_template_parm): Renamed from
475 cp_constrained_type_template_parm.
476 (cp_parser_constrained_template_template_parm): Renamed from
477 cp_constrained_template_template_parm.
478 (constrained_non_type_template_parm): Renamed from
479 cp_constrained_non_type_tmeplate_parm.
480 (finish_constrained_parameter): Renamed from
481 cp_finish_constrained_parameter.
482 (maybe_type_parameter): Renamed from cp_maybe_type_parameter.
483 (declares_type_parameter): Renamed from cp_declares_type_parameter.
484 (declares_type_template_parameter): Renamed from
485 cp_declares_type_template_parameter.
486 (declares_template_template_parameter): Renamed from
487 cp_declares_template_template_parameter.
488 (cp_parser_type_parameter): Call
489 cp_parser_default_type_template_argument and
490 cp_parser_default_template_template_argument which were already
491 factored out from this function.
492 (cp_maybe_constrained_type_specifier): Use the new INTRODUCED_PARM_DECL
493 instead of PLACEHOLDER_EXPR.
494 (cp_parser_requires_expr_scope): Remove old comment and change
495 destructor to use pop_bindings_and_leave_scope.
496 (cp_parser_requires_expression): Remove old comment.
497 (get_concept_from_constraint): Remove old comment.
498 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Changed expected
499 errors now that missing concept definitions are diagnosed earlier.
501 2014-11-11 Jason Merrill <jason@redhat.com>
503 * gcc/cp/call.c (add_function_candidate): Move constraint check after
506 * gcc/cp/class.c (get_member_fn_template)
507 (are_constrained_member_overloads): Remove.
508 (add_method): Call equivalently_constrained directly.
510 2014-11-03 Jason Merrill <jason@redhat.com>
512 * gcc/cp/parser.c (cp_parser_nonclass_name): Fix merge error.
514 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
516 Fixing user-reported issues and regressions
517 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
518 Only pop access checks on failed parsing.
519 * gcc/cp/pt.c (type_dependent_expr_p): Always treat a
520 requires-expr as if dependently typed. Otherwise, we try to
521 evaluate these expressions when they have dependent types.
522 * gcc/cp/constriant.cc (normalize_stmt_list): Remove unused
524 (normalize_call): Don't fold constraints during normalization.
525 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Update diagnostics.
527 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
529 Fix another introduction regression.
530 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
531 Only pop access checks on failed parsing.
533 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
535 Fix regression related to concept introductions.
536 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
537 Pop deferred access checks afer parsing the introduction.
539 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
541 Fix bug related to cleanup expressions in concept definitions.
542 * gcc/cp/constraint.cc (check_function_concept): See through
543 cleanup handlers when checking the body of a function.
544 (normalize_cast): Removed. Handled in a default case.
545 (normalize_cleanup_point): New. Normalize the expression without
548 2014-09-25 Andrew Sutton <andrew.n.sutton@gmail.com>
550 Explicitly disallow function concepts with deduced return types.
551 * gcc/cp/constraint.cc (check_function_concept): Remove check
552 for deduced return type.
553 * gcc/cp/decl.c (check_concept_fn): Explicitly check for
555 * gcc/testsuite/g++.dg/concepts/fn-concept2.C: New.
557 2014-09-24 Andrew Sutton <andrew.n.sutton@gmail.com>
559 Check requirements on function concept definitions.
560 * gcc/cp/decl.c (finish_function): Check properties of a function
562 * gcc/cp/constraint.cc (check_function_concept): New. Check
563 for deduced return type and multiple statements.
564 (normalize_misc): Don't normalize multiple statements.
565 (normalize_stmt_list): Removed.
566 * gcc/cp/cp-tree.h (check_function_concept): New.
567 * gcc/testsuite/g++.dg/concepts/fn-concept1.C: New.
569 2014-09-04 Braden Obrzut <admin@maniacsvault.net>
571 Implement concept introductions.
572 * gcc/cp/constraint.cc (deduce_concept_introduction): New.
573 (build_concept_check): Allow arg to be NULL to skip placeholder.
574 (process_introduction_parm): New.
575 (finish_concept_introduction): New.
576 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Mark introduced parm.
577 * gcc/cp/cp-tree.def: New INTRODUCED_PARM_DECL.
578 * gcc/cp/parser.c (cp_parser_declaration): Tentatively parse for
579 concept introduction.
580 (cp_parser_introduction_list): New.
581 (cp_parser_member_declaration): Tentatively parse for concept
583 (cp_parser_template_introduction): New.
584 (cp_parser_template_declaration_after_export): Parse concept
586 * gcc/cp/pt.c (convert_template_argument): Treat INTRODUCED_PARM_DECL
588 (coerce_template_parms): If INTRODUCED_PARM_DECL represents a pack then
589 match the entire parameter pack of the template.
590 (type_dependent_expression_p): Treat INTRODUCED_PARM_DECL as a
592 * gcc/testsuite/g++.dg/concepts/introduction1.C: New.
593 * gcc/testsuite/g++.dg/concepts/introduction2.C: New.
594 * gcc/testsuite/g++.dg/concepts/introduction3.C: New.
595 * gcc/testsuite/g++.dg/concepts/introduction4.C: New.
596 * gcc/testsuite/g++.dg/concepts/introduction5.C: New.
598 2014-09-01 Andrew Sutton <andrew.n.sutton@gmail.com>
600 Fixing normalization in the presence of constructor calls.
601 * gcc/cp/constraint.cc (normalize_misc): Handle constructor
603 * gcc/testsuite/g++.dg/concepts/req7.C: New.
605 2014-08-29 Andrew Sutton <andrew.n.sutton@gmail.com>
607 Fixing partial-template-id bug.
608 * gcc/cp/parser.c (cp_parser_type_name): If the returned type-decl
609 is actually a shorthand declaration, don't simulate an error.
610 * gcc/testsuite/g++.dg/concepts/template-parm10.C: New.
612 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
614 Add tests for constrained friends.
615 * gcc/testsuite/g++.dg/concepts/friend1.C: New.
616 * gcc/testsuite/g++.dg/concepts/friend2.C: New.
618 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
620 * gcc/cp/decl.c (is_concept_var): Coding style fix.
622 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
624 Fixing regression in scoping rules for templates.
625 * gcc/cp/semantics.c (fixup_tmeplate_type): Lift check to
626 finish_template_type.
627 (finish_template_type): Only do this when concepts are enabled,
628 and also when the class is actually a template. For non-dependent
629 types there are no actions to be taken.
631 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
633 Additional declaration restrictions on variable concepts.
634 * gcc/cp/decl.c (is_concept_var): New.
635 (cp_finish_decl): Check for uninitialized variable
637 (grokvardecl): Don't set the concept flag for non-template variables.
638 * g++.dg/concepts/decl-diagnose.C: Add tests.
640 2014-08-19 Ville Voutilainen <ville.voutilainen@gmail.com>
642 Ban static member function concepts.
643 * gcc/cp/decl.c (grokdeclarator): Diagnose static member function
645 * g++.dg/concepts/decl-diagnose.C: Adjust.
646 * g++.dg/concepts/mem-concept-err.C: Adjust.
647 * g++.dg/concepts/mem-concept.C: Adjust.
649 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
651 Fixes to variable concept implementation.
652 * gcc/cp/cp-tree.h (variable_concept_p): New.
653 * gcc/cp/parser.c (cp_parser_nonclass_name): Check for concepts,
655 * gcc/cp/decl.c (grokvardecl): Label concepts as concepts.
656 * gcc/cp/constraint.cc (check_call): New.
657 (normalize_call): Ensure that calls are probably to functions.
658 (normalize_template_id): Update diagnostics.
659 (finish_template_constraints): Mark assumptions as an error if
660 constraint normalization fails. This was causing normalization
661 to be run twice during the construction of a single declaration.
662 * gcc/testsuite/g++.dg/concepts: Update tests.
664 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
667 * gcc/cp/pt.c (value_dependent_expression_p): Don't assume
668 that all nodes have operands.
670 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
672 Implement normalization checks.
673 * gcc/cp/constraint.cc (normalize_expr): Delegate cast and
674 atomic nodes to a dedicated function.
675 (check_logical): Check that an && or || does not resolve to a
676 user-defined function.
677 (normalize_logical): Check operators and save the locaiton of
679 (normalize_call, normalize_var): Remove spurios error messages.
680 (normalize_cast): New, delegates to normalize atom.
681 (normalize_atom): Check that instantiated expressions can be
683 (tsubst_constraint_info): Re-normalize the associated constraints
684 to check for post-substitution restrictions.
685 * gcc/cp/cp-tree.h (xvalue_result_type): Add to header.
687 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
689 * gcc/testsuite/g++.dg/concepts: Renamed ttp* to template-parm*,
692 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
694 * gcc/cp/class.c (resolve_address_of_overloaded_function): Check
696 * gcc/cp/decl.c (grokfndecl): For now, disallow constrained
697 non-template functions.
698 * gcc/testsuite/g++.dg/concepts: New tests.
700 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
702 * gcc/cp/parser.c (get_id_declarator, get_identifier): New helper
704 (cp_check_constrained_type_parm): Don't fail on null declarators.
705 (cp_finish_constrained_parameter): Remove redundant processing for
706 checking declarations.
707 (cp_maybe_type_parameter, cp_declares_type_parameter,
708 cp_declares_type_template_parameter,
709 cp_declares_template_template_parameter): New helper functions for
710 determining when a parameter declaration is actually a constrained
712 (cp_parser_default_type_template_argument,
713 cp_parser_default_template_template_argument): Parsing support
714 for argument types of default arguments.
715 (cp_parser_template_parameter): Finish constrained parameters
716 after all variadic and default arg checks.
717 (cp_parser_parameter_declaration): Parse default arguments
718 differently if the parameter actually declares a type parameter.
719 * gcc/testsuite/g++.dg/concepts: New tests.
721 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
723 * gcc/testsuite/g++.dg/concepts/explicit-spec6.C: New test.
725 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
727 Fix regression in bootstrap.
728 * gcc/cp/call.c (get_temploid): Removed. No longer called.
729 (joust): Remove unused variable declarations.
731 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
733 Implement deduction-based explicit instantiation and specialization.
734 * gcc/cp/call.c (joust): Allow all non-templates to be ordered by
736 * gcc/cp/pt.c (get_class_bindings): Remove superfluous parameter and
737 move constraint check into most_specialized_class.
738 (most_constrained_function): Order functions with the same signatures
739 by their constraints.
740 (determine_specialization): Candidates must satisfy constraints. Also,
741 order non-template candidates by constraints. Improve diagnostics
742 for instances where candidates are rejected.
743 (more_specialized_inst): New. Compare function templates.
744 (most_specialized_instantiation): Refactor to use
745 more_specialized_inst and order by constraints.
746 (most_specialized_class): Candidates must satisfy constraints.
747 * gcc/cp/decl.c (various) Cosmetic fixes.
748 (adjust_fn_constraints): Rewrite so that class template constraints
749 are not imposed on member function declarations.
750 * gcc/testsuite/g++.dg/concepts: New tests.
752 2014-08-13 Braden Obrzut <admin@maniacsvault.net>
754 * gcc/cp/constraint.cc (deduce_constrained_parameter): Deduce concept
755 from variable concept template-id expressions.
756 (normalize_var): New.
757 (normalize_template_id): Identify variable concepts.
758 (build_concept_check): Handle variable concepts.
759 (finish_shorthand_requirement): Handle variable concepts.
761 (diagnose_node): Identify variable concepts.
762 * gcc/cp/decl.c (grokvardecl): Pass concept flag through to
763 check_explicit_specialization.
764 (grokdeclarator): Allow variable concepts and pass concept flag through
766 * gcc/cp/parser.c (cp_is_constrained_parameter): Accept variable
768 (cp_parser_nonclass_name): Accept variable concepts.
769 (get_concept_from_constraint): Handle variable concepts.
770 * gcc/cp/pt.c (tsubst_copy_and_build): Lookup variable templates.
771 (value_dependent_expression_p): Check requires expressions for value
773 * gcc/cp/semantics.c (finish_call_expr): Don't instantiate variable
774 templates if processing a template declaration.
775 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Change expected error
776 as variable concepts are now handled.
777 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: New test.
778 * gcc/testsuite/g++.dg/concepts/var-concepts2.C: New test.
780 2014-08-11 Andrew Sutton <andrew.n.sutton@gmail.com>
782 * gcc/cp/pt.c (tsubst): Don't short circuit substitution into
783 types when processing constraints. Also, avoid asserting when
784 substituting into template parameters.
785 * gcc/cp/constraint.c (tsubst_constraint_expr): Indicate that
786 constraint processing is happening.
787 (tsubst_constraint_info): Just substitute directly into the
788 normalized constraints instead of re-normalizing.
789 (diagnose_constraints): Adjust template arguments when
790 diagnosing template constraint failures.
791 * gcc/cp/logic.cc (decompose_assumptions): Handle null assumptions.
793 2014-08-08 Andrew Sutton <andrew.n.sutton@gmail.com>
795 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Don't re-normalize
796 constraints, it's already been done.
797 * gcc/cp/cp-tree.h (*_requirement[s]): Renamed to *_constraint[s] to
798 reflect wording in specification. Removed reduce_requirements.
799 * gcc/cp/pt.c (process_template_parm, tsubst_pack_conjunction): Update
801 (fn_type_unification): Remove constraint check.
802 * gcc/cp/parser.c (cp_parser_type_parameter,
803 cp_parser_trailing_requirements,
804 cp_parser_template_declaration_after_export,
805 synthesize_implicit_template_parm): Update from renaming.
806 * gcc/cp/constraint.cc: Renamed a lot of functions to reflect wording
808 (finish_template_constraints): Normalize associated constraints.
809 (tsubst_constraint_expr): Renamed from instantiate_requirements.
810 Normalize associated constraints.
811 (check_satisfied): Return true if the arguments refer to template
813 (all_constraints_satisfied, any_conjunctions_satisfied,
814 check_requirements): No longer needed.
815 (check_diagnostic_constraints): Just normalize the expression, don't
818 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
820 * gcc/testsuite/g++.dg/concepts/concepts.exp: Add missing argument
823 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
825 * gcc/cp/constraints.c (tsubst_requires_body, instantiate_requirements):
826 Lift the unevaluated operand guard to the entire constraint expression.
827 (check_satisfied, all_constraints_satisfied,
828 any_conjunctions_satisfied): Rewrite constraint checking to use
829 atomic constraints. Prevents instantiation of concepts.
830 (check_diagnostic_constraints): Recursively decompose and check
831 constraints for fine-grain diagnostics.
832 (diagnose_*): Use new constraint checking function.
835 2014-07-30 Braden Obrzut <admin@maniacsvault.net>
837 * gcc/cp/parser.c (cp_parser_trailing_requirements): Handle requires
838 keyword manually so that we can push function parameters back into
840 * gcc/cp/decl.c (push_function_parms): New. Recovers and reopens
841 function parameter scope from declarator.
842 * gcc/testsuite/g++.dg/concepts/req*.C: New tests.
844 2014-07-30 Andrew Sutton <andrew.n.sutton@gmail.com>
846 * gcc/testsuite/g++.dg/concepts/test.C: Removed.
848 2014-07-28 Andrew Sutton <andrew.n.sutton@gmail.com>
850 * gcc/cp/cp-tree.h (more_constraints): Remove
851 (subsumes_constraints): Renamed from more_constraints
852 (more_constrained): Repurposed
853 * gcc/cp/call-c (template_decl_for_candidates): Rename to get_temploid,
854 only get template info for member functions of a class template
856 (joust): Handle member functions of class template specializations
857 separately from function templates. This matches the new wording in
859 * gcc/cp/logic.cc (match_terms): Make inline.
860 (subsumes_constraints): Rename to subsumes_constraints_nonnull.
861 * gcc/cp/pt.c (is_compatible_template_arg): Use subsumes.
862 (more_specialized_fn): Use usubsumes_constraints.
863 (more_specialized_class): Use more_constrained.
864 * gcc/cp/constraint.cc (more_constraints): Removed.
865 (more_constrained): New.
867 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
869 * gcc/cp/typeck.c (cp_build_function_call_vec): Emit diagnostic
870 at the input location.
871 * gcc/cp/error.c (dump_template_decl): Constraints are never invalid
872 in this way. Also fixes brace warning.
874 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
876 * gcc/cp/tree.c (cp_tree_equal): compare constraint infos by
877 their associated constraints (patch by Braden Obrzut).
878 * gcc/cp/logic.c (decompose_assumptions): Don't decompose errors.
879 (subsumes_constraints): Update to use new macros.
880 * gcc/cp/cp-tree.h (tree_constraint_info): Rewrite constraints
881 to cache leading, trailing, and associated requirements.
882 (CI_SPELLING, CI_REQUIREMENTS): Remove
883 (CL_LEADING_REQS, CI_TRAILING_REQS, CI_ASSOCIATED_REQS): New
884 accessors for constraint info field.
885 (save_leading_requirements, save_trailing_requirements,
886 valid_template_requirements_p): New.
887 (make_constraints): Removed.
888 (instantiate_requirements): Add flag to substitute in either
889 dependent/non-dependent mode.
890 (tsubst_constraint_info): New.
891 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_clause): New.
892 * gcc/cp/cxx-pretty-print.c (pp_cxx_init_declarator): Remove.
893 (pp_cxx_function_definition): Print trailing constraints if they
895 (pp_cxx_init_declarator): New. Print trailing requirements.
896 (pp_cxx_template_declaration): Print leading requirements.
897 (pp_cxx_requires_clause): New.
898 * gcc/cp/pt.c (build_template_decl): Ensure completion of constraints
899 when associating them with the template.
900 (add_inherited_template_parms): Update to new constraint mechanisms.
901 (redeclare_class_template): Update to new constraint mechanisms.
902 (tsubst_decl): Update to new constraint mechanism.
903 * gcc/cp/parser.c (cp_parser_lambda_expression): Save off constraints
905 (cp_check_constrained_type_parm): Save leading requirements instead
907 (cp_parser_trailing_requirements): Simplify by just saving the trailing
909 (cp_parser_init_declarator): Save off constraints before parsing the
911 (cp_parser_member_declaration): Save off requirements before parsing
913 (cp_parser_requires_clause): Defer constexpr check until as late as
915 (cp_parser_template_declaration_after_export): Save leading requirements
916 instead of finishing them.
917 (synthesize_implicit_template_parm): Save leading requirements when
918 processing a constrained-type-specifier.
919 * gcc/cp/class.c (get_member_fn_template): Update to use new constraint
921 * gcc/cp/call.c (constraint_failure): Renamed from
922 template_constraint_failure. Produce reasons for non-template functions.
923 (is_constrainable_non_template_fn): Removed.
924 (add_function_candidate): Use new constraint association framework.
925 * gcc/cp/ptree.c (cxx_print_xnode): Dump leading, trailing requirements.
926 * gcc/cp/error.c (dumpl_template_decl): Print a leading requires-clause.
927 (dump_function_decl): Print a trailing requires-clause.
928 * gcc/cp/semantics.c (finish_template_template_parm): Finish
929 template constraints before associating them.
930 * gcc/cp/constraint.cc (reduce_call): Don't fold constants when
932 (reduce_template_id): Replace EXPR_LOCATION in diagnostics. Return
933 error_mark_node instead of corrected call expression.
934 (reduce_requirements): Don't normalize a null expression.
935 (make_constraints): Removed.
936 (get_constraints): Updated.
937 (set_constraint): Updated.
938 (get_shorthand_requirements): Use the appropriate macro.
939 (build_constraint_info, init_leading_requirements,
940 init_trailing_requirements, update_leadng_requirements,
941 update_trailing_requirements, save_leading_requirements,
942 save_trailing_requirements): New.
943 (finish_template_requirements): Analyze and decompose constraints.
944 (valid_template_requirements_p): New.
945 (instantiate_requirements): New flag.
946 (tsubst_constraint_info): New.
947 (check_requirements): Update.
948 (check_constraints): Add another round of instantiation to ensure
949 that all non-constexpr exprs are folded out of the expression.
950 (check_constraints): Update.
951 (equivalent_constraints): Redefine constraint equivalence in terms
952 of tokens (patch by Braden Obrzut).
953 (diagnose_trait, diagnose_check, diagnose_requires,
954 diagnose_constraints): Update.
955 * gcc/cp/decl2.c (check_classfn): Update constraint mechanisms.
956 * gcc/cp/decl.c (decls_match): Update to use new constraints.
957 (duplicate_decls): members match if they have equivalent constraints.
958 (get_leading_template_requirements): New.
959 (adjust_out_of_class_fn_requirements): New.
960 (grokfndecl): Associate requirements with a function declaration.
961 * gcc/testsuite/g++.dg/concepts/*: New tests.
963 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
965 * gcc/c-family/c.opt (flag_concepts): Don't enable by default.
966 * gcc/c-family/c-opts.c (set_std_cxx1z): Enable concepts if
967 -std=cxx1z is selected.
968 * gcc/c-family/c-format.c (gcc_cxxdia): Add "Z" as format specifier.
969 * gcc/cp/c-common.c (cxx_dialect): Make -std=c++98 the default
971 * gcc/cp/lex.c (cxx_init): Don't set flag_concepts explicitly.
972 * gcc/testsuite/g++.dg/concepts/*.C: Update build flags.
974 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
976 * gcc/cp/cp-tree.h (DECL_CONSTRAINTS): Remove this macro; use
977 get_constraints instead.
978 (set_constraints): new.
979 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Use
981 * gcc/cp/pt.c (get_specialization_constraints): Use get_constraints.
982 (build_template_decl): Use get_constraints.
983 (process_partial_specialization): Use get_constraints.
984 (add_inherited_template_parms): Use get_constraints.
985 (redeclare_class_template): Use get_constraints.
986 (is_compatible_template_arg): Use get_constraints.
987 (tsubst_friend_class): Use get_constraints.
988 (tsubst_decl): Uset get_constraints.
989 * gcc/cp/semantics.c (finish_template_template_parm): Use
991 (fixup_template_type): Use get_constraints.
992 * gcc/cp/constraint.cc (constraints): New global association
993 of declarations to constraints.
994 (get_constraints): Return the associated constraints from the
996 (set_constraints): New. Associate constraints with a declaration.
997 (check_template_constraints): Use get_constraints.
998 (equivalently_constrained): Use get_constraints.
999 (more_constrained): Use get_constraints.
1000 (diagnose_constraints): Use get_constraints.
1001 * gcc/testsuite/g++.dg/concepts/partial-spec.C: New.
1003 2014-06-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1005 * gcc/cp/parser.c (cp_parser_requires_clause): Don't fold expressions
1006 when parsing a requires-clause.
1007 * gcc/cp/constraint.cc (reduce_requirements): Don't fold
1008 expressions during constraint normalization.
1010 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1012 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): Defer
1013 handling the BASELINK check until concept-resolution in order to
1014 allow member conceps.
1015 (cp_parser_nonclass_name): Also Check for concept-names when the
1016 lookup finds a BASELINk.
1017 * gcc/cp/constraint.cc: (resolve_constraint_check) If the call
1018 target is a base-link, resolve against its overload set.
1019 (build_concept_check): Update comments and variable names to
1020 reflect actual processing.
1021 * gcc/testuite/g++.dg/concepts/mem-concept.C: New test.
1022 * gcc/testuite/g++.dg/concepts/mem-concept-err.C: New test.
1024 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1026 * gcc/cp/error.c (dump_expr): Pretty print placeholder to improve
1029 2014-06-17 Braden Obrzut <admin@maniacsvault.net>
1031 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): If getting
1032 a baselink, use the referred-to function/overload declarations rather
1035 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
1037 * gcc/cp/constraint.cc (deduce_constrained_parameter): Refactor
1038 common deduction framework into separate function.
1039 (build_call_check): New.
1040 (build_concept_check): Take additional arguments to support the
1041 creation of constrained-type-specifiers from partial-concept-ids.
1042 (build_constrained_parameter): Take arguments from a partial-concept-id.
1043 * gcc/cp/cp-tree.h (build_concept_check, biuld_constrained_parameter):
1044 Take a template argument list, defaulting to NULL_TREE.
1045 * gcc/cp/parser.c (cp_parser_template_id): Check to see if a
1046 template-id is a concept check.
1047 (cp_check_type_concept): Reorder arguments
1048 (cp_parser_allows_constrained_type_specifier): New. Check contexts
1049 where a constrained-type-specifier is allowed.
1050 (cp_maybe_constrained_type_specifier): New. Refactored common rules
1051 for concept name checks.
1052 (cp_maybe_partial_concept_id): New. Check for
1053 constrained-type-specifiers.
1054 * gcc/testuite/g++.dg/concepts/partial.C: New tests.
1055 * gcc/testuite/g++.dg/concepts/partial-err.C: New tests.
1056 * gcc/testuite/g++.dg/concepts/concepts.exp: Add missing test driver.
1058 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
1060 * gcc/cp/parser.c (cp_check_type_concept): New.
1061 (cp_check_concept_name): Remove redundant condition from check.
1062 Diagnose misuse of non-type concepts in constrained type specifiers.
1063 * gcc/testuite/g++.dg/concepts/generic-fn.C: Add tests for
1064 non-simple constrained-type-specifiers and nested-name-specifiers
1066 * gcc/testuite/g++.dg/concepts/generic-fn-err.C: New tests for
1067 diagnosing ill-formed programs.
1069 2014-06-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1071 * gcc/cp/cp-tree.h (build_constrained_parameter): Renamed fro
1072 describe_tempalte_parm.
1073 * gcc/cp/parser.c (cp_check_constrained_type_parm): New. Prevent
1074 declaration of cv-qualifed or non-id types.
1075 (cp_constrained_type_template_parm): Renamed, check for invalid
1077 (cp_constrained_template_template_parm): Renamed, check for invalid
1079 (cp_constrained_non_type_tmeplate_parm): Renamed.
1080 (cp_finish_constrained-parameter): Support checking of decarlarations.
1081 (cp_check_concept_name): Renamed. Add initial support for auto
1082 and constrained-type-specifiers in compound requirements.
1083 (cp_parser_nonclass_name): Only check for concept names if -fconcepts
1085 (cp_manage_requirements): New RAII guard for managinging the
1086 current_template_reqs variable during declaration parsing.
1087 (cp_paresr_trailing_requirements): Refactored common parsing
1088 requirements from cp_parser_init_declarator and
1089 cp_parser_member_declarator. Take terse constraints from implicit
1090 parameter declarations.
1091 (cp_parser_init_declarator): Cleanup, refactor requirement logic.
1092 (cp_parser_type_id_1): Allow auto in compound requirements.
1093 (cp_parser_member_declaration): Cleanup, refactor requirement logic.
1094 (cp_parser_compound_requirement): Note parsing state for the
1095 trailing-type-id so we can get auto and constrained-type-specifiers.
1096 (cp_parser_function_definition_after_decl): Remove broken constraint
1098 * gcc/cp/parser.h (cp_parser): New member.
1099 * gcc/cp/constraint.cc (finish_validtype_expr): Initial (non-)handling
1100 of auto in type requirements.
1101 (finish_concept_name): Moved to cp_check_concept_name.
1102 * gcc/testuite/g++.dg/concepts/constrained-parm.C: New test.
1103 * gcc/testuite/g++.dg/concepts/generic-fn.C: New test.
1106 2014-03-10 Andrew Sutton <andrew.n.sutton@gmail.com>
1108 * gcc/testuite/g++.dg/concepts/fn1.C: New test.
1109 * gcc/testuite/g++.dg/concepts/fn2.C: New test.
1111 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1113 * gcc/cp/parser.c (synthesize_implicit_template_parm): Allow concepts
1114 to declare implicit template parameters. Only synthesize new parameters
1115 if the concept name is new.
1116 (finish_concept_name): Moving into parser.c for the time being. Needs
1117 to be rewritten to remove duplicate code between parser.c and
1120 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1122 * gcc/cp/pt.c (tsubst_copy): Expand pack expansions as conjunctions.
1124 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1126 * gcc/cp/pt.c (tsubst_pack_conjunction): Don't try to conjoin
1127 dependent expressions.
1129 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
1131 * gcc/cp/semantics.c (fixup_template_type): Compare primary template
1132 types to specializations using structural types so we don't run into
1133 canonical type errors with constrained specializations.
1135 2013-11-08 Andrew Sutton <andrew.n.sutton@gmail.com>
1137 * gcc/cp/pt.c (add_inherited_template_parms): Instantiate requirements
1138 in a processing template decl context.
1140 2013-11-05 Andrew Sutton <andrew.n.sutton@gmail.com>
1142 * gcc/cp/semantics.c (fixup_template_type): Add a same-type check
1143 for specialiations so we don't accidentally match non-dependent
1144 specializations having a different type.
1146 2013-10-26 Ville Voutilainen <ville.voutilainen@gmail.com>
1148 * gcc/cp/decl.c (grokdeclarator): Reject concept keyword
1149 in typedefs, function parameters, data members, non-static
1150 member functions and variables. Allow static member functions
1153 2013-10-30 Andrew Sutton <andrew.n.sutton@gmail.com>
1155 * gcc/cp/semantics.c (fixup_template_type): Don't emit errors when
1156 no templates can be found with matching constraints.
1158 2013-10-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1160 * gcc/cp/parsre.c (cp_parser_requires_expression): Gracefully
1161 fail when parsing a requires expr outside a template.
1163 2013-10-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1165 * gcc/cp/c-common.c (c_common_r): Remove unused keywords "assume",
1166 "axiom", and "forall".
1167 * gcc/cp/c-common.h (rid): Removed unused reserved word ids.
1169 2013-10-24 Edward Smith-Rowland <3dw4rd@verizon.net>
1171 * gcc/cp/typeck.c (cp_build_function_call_vec): Use unused variable
1174 2013-10-23 Andrew Sutton <andrew.n.sutton@gmail.com>
1176 * gcc/cp/class.c (get_member_fntemplate): New.
1177 (are_constrained_member_overloads): Only get a template declaration
1178 if the member function is, in fact, a template or temploid.
1179 * gcc/cp/pt.c (check_explicit_specialization): Do not allow
1180 explicit specializations to be declared 'concept', and do not allow
1181 an explicit specialization of a concept.
1182 * gcc/cp/decl.c (grokfndecl): Propagate the concept flag to
1183 check_explicit_specialization.
1185 2013-10-22 Andrew Sutton <andrew.n.sutton@gmail.com>
1187 * gcc/c-family/c-common.c (cxx_dialect): Make the default
1189 * gcc/cp/constraint.cc (check_constrained_friend): Don't assert
1192 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1194 * gcc/cp/logic.cc (left_requires), (decompose_left): Add
1195 decomposition rules for requires expressions.
1196 (subsumes_requires), (subsumes_prop): Add subsumption rules for
1197 requires expressions.
1198 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failed conversion
1201 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1203 * gcc/cp/constraint.cc (finish_concept_name): Allow functions with
1204 the same name as concepts to resolve as call expressions in the
1207 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1209 * gcc/cp/constraint.cc (conjoin_requiremens): New.
1210 (resolve_constraint_check): Filter non-concept candidates before
1211 coercing arguments. Perform deduction in a template-decl processing
1212 context to prevent errors during diagnosis.
1213 (finish_concept_name), (finish_shorthand_requirement),
1214 (get_shorthand_requirements): New.
1215 * gcc/cp/pt.c (template_parm_to_arg): Make non-static.
1216 (process_templat_parm): Build shorthand requirements from the
1217 parameter description.
1218 (end_templat_parm_list): New.
1219 (convert_placeholder_argument): New.
1220 (convert_template_argument): Match placeholder arguments against
1221 any template parameter.
1222 (tsubst_pack_conjuction): New.
1223 (tsubst_expr): Expand a pack as a conjunction.
1224 (type_dependent_expression_p): Placeholders are always type
1226 * gcc/cp/parser.c (cp_is_constrained_parameter),
1227 (cp_finish_template_type_parm), (cp_finish_template_template_parm)
1228 (cp_finish_non_type_template_parm), (cp_finish_constrined_parameter):
1230 (cp_parser_template_parameter): Handle constrained parameters.
1231 (cp_parser_nonclass_name): An identifier naming an overload set
1232 may declare a constrained parameter.
1233 (cp_parser_type_parameter), (cp_parser_template_declaration_after_exp):
1234 Get shorthand requirements from the tmeplate parameter list.
1235 * gcc/cp/cp-tree.h (TEMPLATE_PARM_CONSTRAINTS): New.
1237 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1239 * gcc/cp/cp-tree.h (check_constrained_friend): Take requirements as
1241 * gcc/cp/constraints.cc (check_constrained_friend): Do not diagnose
1242 errors in unconstrained friend declarations.
1243 * gcc/cp/parser.cc (cp_parser_member_declaration): Pass current
1244 requirements to check_constrained_friend.
1246 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1248 * gcc/cp/parser.c (cp_parser_member_declaration): Check that
1249 a constrained friend definition is valid.
1250 * gcc/cp/decl.c (grokfndecl): Disallow constrained friend template
1252 * gcc/cp/constraints.cc (check_constrained_friend): New.
1253 * gcc/cp/typeck.c (cp_build_function_call_vec): Diagnose constraints
1254 in the presence of the failure of a single candidate.
1255 * gcc/cp/cp-tree.h (check_constrained_friend): New.
1256 * gcc/cp/call.c (is_non_template_member_fn): Make inline.
1257 (is_non_template_friend), (is_constrainable_non_template_fn): New.
1258 (add_function_candidate): Predicate check on
1259 is_constrainable_non_template_fn.
1261 2013-09-10 Andrew Sutton <andrew.n.sutton@gmail.com>
1263 * gcc/cp/cp-tree.h (TEMPLATE_PARMS_CONSTRAINTS): New.
1264 * gcc/cp/parser.c (cp_parser_template_declaration_after_export),
1265 (cp_parser_type_parameter): Use TEMPLATE_PARMS_CONSTRAINTS.
1266 * gcc/cp/semantics.c (fixup_template_scope): Use
1267 TEMPLATE_PARMS_CONSTRAINTS.
1269 2013-09-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1271 * gcc/cp/cxx-pretty-print.c (pp_cxx_compound_requirement),
1272 (pp_cxx_type_requirement), (pp_cxx_validtype_expr): Use
1273 pp->type_id() instead of pp_cxx_type_id().
1275 2013-09-09 Andrew Sutton <andrew.n.sutton@gmail.com>
1277 * gcc/cp/pt.c (get_class_bindings): Pass the partial specialization
1278 for constraint evaluation. Evaluate constraints, resulting in
1279 deduction failure on error.
1280 (get_specializaing_template_decl), (get_specialization_constraints),
1281 (maybe_new_partial_specialization): New.
1282 (maybe_process_partial_specialization): Allow the creation of
1283 new types for constrained partial specializations.
1284 (process_partial_specialization): Modify the canonical type
1285 of constrained partial specializations.
1286 (instantiate_class_template_1): Do not explicitly check constraints
1287 during class template instantiation.
1288 (tsubst_decl): Instantiate the constraints of template declarations.
1289 (more_specialized_class): Pass specializations to get_class_bindings().
1290 Compare specialization constraints if the types are equivalent.
1291 (most_specialized_class): Pass specialization to get_class_bndings().
1292 * gcc/cp/decl2.c (check_class_fn): Get the decl's requirements from
1293 either the current template reqs or from the template parameters.
1294 Allow overloading of constrained out-of-class member definitions.
1295 * gcc/cp/semantics.c (fixup_template_type): New. Match the template
1296 scope to a specialization with appropriate constraints.
1297 (finish_template_type): Fix template type when entering scope.
1298 * gcc/cp/parser.c (cp_parser_parse_type_parameter): Attach
1299 requirements to the current template parameter list.
1300 (cp_parser_init_declarator): Parse requires clauses for out-of-class
1301 member definitions. Be sure to restore current constraints before
1302 exiting the function.
1303 (cp_parser_member_declarator): Restore the previous requirements in
1304 an early-exit branch.
1305 (cp_parser_late_parsing_for_member): Restore constraints after
1306 maybe_end_member_template_processing().
1307 (cp_parser_template_declaration_after_exp): Attach constraints to
1308 the current template parameters.
1309 * gcc/cp/constraint.cc (reduce_template_id): Don't crash when
1310 omitting ()'s on constraint calls.
1311 (check_requirements): Don't evaluate dependent arguments.
1312 (check_constraints): Don't try to evaluate when arguments are
1314 (equivalent_constraints): Optimize the case when a and b are the
1317 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1319 * gcc/cp/semantics.c (trait_expr_value): Evaluate __is_same_as.
1320 (finish_trait_expr): Check __is_same_as and __is_convertible_to.
1321 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failures in
1323 * gcc/cp/parser.c (cp_parser_primary_expression),
1324 (cp_parser_trait_expr): Parse __is_same_as.
1325 * gcc/cp/cp-tree.h (cp_trait_kind): Add CPTK_IS_SAME_AS.
1326 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Pretty print
1329 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1331 * gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
1332 requires expr parameter list.
1334 2013-07-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1336 * gcc/cp/parser.c (cp_parser_requires_expr): Update parser using new
1337 requires expression nodes. Renamed some grammar productions to better
1338 reflect the representation of the syntax. Create a new scope for
1339 requires parameters.
1340 (cp_parser_nested_requirement): Wrap results in a NESTED_REQ node.
1341 * gcc/cp/semantics.c (xvalue_result_type): New.
1342 (trait_expr_value): Evaluate __is_convertible_to.
1343 (finish_requires_expr): Implemented, along with other functions to
1344 construct and evaluate nodes for template constraints.
1345 (potential_constant_expression_1): Handle requires expressions.
1346 (finish_template_requirements), (finish_requires_expr), etc:
1347 Move to constraint.cc.
1348 * gcc/cp/cp-tree.def: (REQUIRES_EXPR), (EXPR_REQ), (TYPE_REQ),
1349 (NESTED_REQ), (VALIDEXPR_EXPR), (VALIDTYPE_EXPR), (CONSTEXPR_EXPR):
1351 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Make new nodes typed.
1352 * gcc/cp/cp-tree.h (finish_expr_requirement),
1353 (finish_type_requirement), (finish_nested_requirement),
1354 (finish_validexpr_expr), (finish_validtype_expr),
1355 (finish_constexpr_expr): New.
1356 * gcc/cp/pt.c (convert_nontype_argument): Use can_convert_standard.
1357 (retrieve_local_specialization), (register_local_specialization),
1358 (extract_fnparm_pack): Make non-static.
1359 (tsubst_expr): Substitution rules for requires expressions.
1360 (instantiate_requirements): Move to constraints.cc
1361 (tsubst_constraint): Remove.
1362 * gcc/cp/call.c (can_convert): Allow user-defined conversions.
1363 (can_convert_standard): New.
1364 * gcc/cp/cvt.c (convert_to_reference): Use can_convert_standard.
1365 * gcc/cp/search.c (check_final_overrider): Use can_cnvert_standard.
1366 * gcc/cp/typeck.c (build_static_cast_1): Use can_convert_standard.
1367 * gcc/cp/error.c (dump_expr): Pretty print new nodes.
1368 * gcc/cp/cxx-pretty-print.c (pp_cxx_primary_expression): Pretty
1369 print new expr/req nodes.
1370 (pp_cxx_requires_expr): New along with related functions for
1371 pretty printing requirements.
1372 (pp_cxx_parameter_declaration_clause): Accommodate "raw" parameter
1373 lists in addition to function decls.
1374 (pp_cxx_requirement_parameter_list): Unified with parameter decl clause.
1375 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_expr): New along with
1376 related functions for pretty printing requirements.
1377 * gcc/cp/logic.cc: Move header comments to top of file.
1378 * gcc/cp/constraint.cc (reduce_requirements): Handle requires
1380 (diagnose_constraints): Rename and handle requires expressions.
1382 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1384 * gcc/cp/error.c (cp_printer): Fix unnecessary whitespace change.
1385 * gcc/cp/constraint.cc (diagnose_node): Don't fail diagnosing
1388 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1390 * gcc/cp/class.c (are_constrained_member_overloads): Fix doc typos.
1392 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1394 * gcc/cp/parser.c (cp_parser_init_declarator): Parse template
1395 requirements for out-of-class member definitions.
1396 * gcc/cp/decl2.c (check_classfn): Include match out-of-class
1397 definitions using constraints.
1398 * gcc/cp/constraint.cc (equivalently_constrained). Use get_constraints.
1399 (more_constrained). Use get_constraints.
1401 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1403 * gcc/cp/cp-tree.h (tree_template_info). Remove constraint from
1405 (check_template_info): Removed (unused).
1406 (TI_CONSTRAINT): Removed (no longer needed) along with related macros.
1407 (DECL_CONSTRAINTS): New. Get constraints from DECL_SIZE_UNIT for
1409 (build_template_info): Removed overload taking constraints.
1410 (get_constraints): Removed (no longer needed).
1411 * gcc/cp/class.c (are_constrained_member_overlaods): Allow constrained
1412 member function templates to be differentiated as overloads.
1413 * gcc/cp/decl.c (decls_match): Only compare constraints on
1415 (grokfndecl): Don't pass constraints to build_template_info.
1416 * gcc/cp/tree.c (bind_template_template_parm): Don't pass constraints
1417 to build_template_info.
1418 * gcc/cp/pt.c (build_template_info): Removed overload taking
1420 (check_explicit_specialization): Don't build new constraints for
1422 (build_template_decl): Pass constraints. Update docs.
1423 (process_partial_specialization): Stub out support for constrained
1424 partial specialiations.
1425 (push_template_decl_real): Build template decls with current template
1426 reqs. Don't pass constraints to build_template_info.
1427 (add_inherited_template_parms): Build new constraints from inherited
1428 template constructors.
1429 (redeclare_class_template): Update to new constraint interface.
1430 (is_compatible_template_arg): Update to new constraint interface.
1431 (lookup_template_class_1): Don't build new constraints or pass them to
1432 build_template_info.
1433 (instantiate_class_template_1): Update to new constraints interface.
1434 (tsubst_decl): Don't build new constraints or pass them to
1435 build_template_info. For function templates, explicitly instantiate
1436 new constraints for member functions of class templates.
1437 * gcc/cp/semantics.c: Associate constraints with template template
1438 parms directly, not through template info.
1439 * gcc/cp/constraint.cc (get_constraints): Simplified to use new constraints
1441 (check_constraints): Update to use new constraints interface.
1442 (equivalently_constrained): Update to use new constraints interface.
1443 (more_constrained): Update to use new constraints interface.
1444 * gcc/cp/parser.cpp (cp_parser_late_parsing_for_member): Update to use
1445 new constraints interface.
1446 * gcc/cp/call.c (is_non_template_member_fn): New.
1447 (add_function_candidate): Only check constraints for non-template member
1450 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1452 * gcc/cp/parser.c (cp_parser_requires_clause): Pulled out of
1453 cp_parser_requires_clause_opt for reuse in the requires expr parser.
1454 (cp_parser_requires_expression): New, along with a family of
1455 sub-expression parsers for the new feature.
1456 * gcc/cp/semantics.c (finish_requires_expr): Stub.
1457 (finish_syntax_requirement): Stub.
1458 (finish_type_requirement): Stub.
1459 (finish_constexpr_requirement): Stub.
1460 (finish_noexcept_requirement): Stub.
1461 (finish_requires_expr): Stub.
1462 * gcc/cp/cp-tree.h: (finish_requires_expr): New.
1463 (finish_syntax_requirement): New.
1464 (finsih_type_requirement): New.
1465 (finish_constexpr_requirement): New.
1466 (finish_noexcept_requirement): New.
1468 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1470 * gcc/cp/error.c (subst_to_string): Allow this to be called explicitly
1471 passing template parameters in the TREE_TYPE and with a null
1473 * constraint.cc (check_requirements): New overload taking template
1475 (check_constraints.cc): Move instantiation and checking into the
1476 new check_requirements overload.
1477 (diagnose_requirements): New family of functions for diagnosing
1478 constraint failures.
1480 2013-06-18 Andrew Sutton <andrew.n.sutton@gmail.com>
1482 * gcc/cp/class.c (are_constrained_member_overloads): New.
1483 (add_method): Allow overloading of constrained member functions.
1484 * gcc/cp/call.c (rejection_reason_code): New rr_constraint_failure.
1485 (template_constraint_failure): New.
1486 (add_function_candidate): Check for viability as a precondition to use.
1487 (add_template_candidate_real): Integrate constraint diagnostics.
1488 Provide constraint info for new template instantiations.
1489 (print_z_candidate): Emit diagnostics for constraint failures.
1490 (template_decl_for_candidate): New.
1491 (joust): Allow non-member templates of class templates to be evaluated
1492 in more_specialized_fn if they are constrained.
1493 * gcc/cp/ptree.c (cxx_print_xnode): Dump constraint info.
1494 * gcc/cp/semantics.c (finish_template_template_parm): Build template
1495 info for template template parameters.
1496 (is_unary_trait): New.
1497 (is_binary_trait): New.
1498 (finish_trait_expr): Check for binary traits using new function.
1499 * gcc/cp/constraint.cc (join_requirements): New
1500 (conjoin_requirements): Join expressions correctly. Fixed docs.
1501 (disjoin_requirements): Removed.
1502 (is_constriant): Removed.
1503 (resolve_constraint_check): New. Replaces previous get_constraint
1504 check and related functions.
1505 (get_constraints): New, along with helper functions.
1506 (suppress_template_processing): New.
1507 (check_template_constraints): New, along with helper functions.
1508 (equivalent_constraints): New.
1509 (equivalently_constrained): New.
1510 (more_constraints): New.
1511 (more_constrianed): New.
1512 (diagnose_constraint_failure): New.
1513 * gcc/cp/decl.c (decls_match): Check for constraint equivalence if
1514 the types are the same.
1515 (check_concept_refinement): New.
1516 (are_constrained_overloads): New.
1517 (duplicate_decls): Handle constraints for ambigous declarations. Check
1518 and diagnose concept refinement.
1519 (check_concept_fn): Don't fail completely just because the concept
1520 isn't defined correctly. Allow analysis to continue as if declared
1521 constexpr. Concepts must return bool.
1522 * gcc/cp/tree.c (bind_template_template_parm): Provide empty
1523 constraints for bound template template parameters.
1524 * gcc/cp/logic.cc: Rewrite of proof state and related structures and
1525 decomposition logic. Removed right-decomposition logic, but retained
1526 right-logical rules.
1527 (match_terms): Renamed from entails.
1528 (subsumes_prop): Cleanup, added specific handlers for and/or cases.
1529 (subsumes_constraints): Update from interface change.
1530 * gcc/cp/cp-tree.h (check_constraint_info): Renamed and applied
1532 (check_template_info): Renamed and applied interface change.
1533 (cp_unevaluated): New
1534 (local_specialization_stack): New.
1535 (coerce_template_parms): New.
1536 (is_unary_trait): New.
1537 (is_binary_trait): New.
1538 (get_constraints): New.
1539 (check_constraints): New.
1540 (check_template_constraints): New.
1541 (subst_template_constraints): New.
1542 (equivalent_constraints): New.
1543 (equivalently_constrained): New.
1544 (more_constraints): New.
1545 (more_constrained): New.
1546 (diagnose_constraints_failure): New.
1547 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Print the
1548 template requirements.
1549 * gcc/cp/pt.c (local_specialization_stack): New.
1550 (build_template_info): Refactor into 3-argument version and
1551 incorporate template requirements.
1552 (check_explicit_specialization): Instantiate requirements for
1554 (push_template_decl_real): Include constraints in template info.
1555 (redeclare_class_template): Diagnose redeclaration with different
1557 (is_compatible_template_arg): New.
1558 (convert_template_argument): Check constraints on template template
1559 arguments and diagnose errors.
1560 (lookup_template_class_1): Check constraints on alias templates.
1561 Keep constraints with instantiated types.
1562 (instantiate_class_template_1): Check constraints on class templates.
1563 (tsubst_decl): Instantiate and keep constraints with template info.
1564 Also, allow dependent pack arguments to produce neww parameter
1565 packs when instantiated.
1566 (coerce_template_parms): New overload.
1567 (tsubst_copy): Handle REAL_TYPE and BOOLEAN_TYPE.
1568 (tsubst_copy_and_build): PARM_DECLs can be instantiated as pack
1569 expansions (used with requires expression).
1570 (fn_type_unification): Check constraints for function templates.
1571 (more_specialized_fn): Determine which candidate is more constrained.
1572 (substitute_template_parameters): Removed.
1573 (tsubst_constraint): New.
1574 (substitute_requirements): New.
1575 * gcc/cp/parser.c: (cp_parser_optional) Removed along with helper
1577 (cp_unevaluated): New.
1578 (cp_parser_type_parameter): Check for requires kw explicitly, and
1579 save/clear template requirements before parsing the requires clause.
1580 (cp_parser_requires_clause): Removed.
1581 (cp_parser_template_declaration_after_exp): Check for requires kw
1583 * gcc/system.h (cstdlib): Removed include.
1584 * gcc/c-family/c-common.h (D_CXX_CONCEPTS): New flag for disabling
1586 * gcc/c-family/c.opt (flag_concepts): Remove redundant declaration.
1587 * gcc/c-family/c-common.c (c_common_r): Concept-specific keywords
1588 are only enabled when concepts are enabled.
1590 2013-06-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1592 * gcc/system.h (cstdlib): Include <cstdlib> to avoid poisoned
1594 * gcc/c-family/common.c (c_common_r): Added __is_same_as intrinsic,
1595 removed previous, unused intrinsics.
1596 * gcc/c-family/common.h (rid): Added RID_IS_SAME_AS.
1597 * gcc/cp/parser.c (take): New.
1598 (cp_requires_clause): New.
1599 (cp_requires_clause_opt): New.
1601 (cp_parser_optional_if_token): New.
1602 (cp_parser_optional_if_not_token): New.
1603 (cp_parser_optional_if_keyword): New.
1604 (cp_parser_decl_specifier_seq): Parse 'concept' as a declspec.
1605 (cp_parser_type_parameter): Parse constrained template template parms.
1606 (cp_parser_member_specification_opt): Parse member constraints after
1607 the declaration, not before.
1608 (cp_parser_template_declaration_after_exp): Rewrote parsing for
1609 template requirements
1610 (cp_parser_late_parsing_for_member): Re-push the current template
1611 requirements when late-parsing member definitions.
1612 * gcc/cp/decl.c (check_concept_fn): New.
1613 (grokfndecl): Semantics for concept declspec.
1614 (grokdeclarator): Semantics for concept declspec.
1615 (xref_tag_1): Update to new interface.
1616 * gcc/cp/constraint.cc (make_constraints): New.
1617 * gcc/cp/cp-objcp-common.c (cp_tree_size): Add case for constraint_info.
1618 * gcc/cp/cp-tree.h (require): New.
1619 (tree_template_info): Add a field for constraint info.
1620 (tree_constraint_info): New.
1621 (constraint_info_p): New.
1622 (template_info_p): New.
1624 (CI_REQUIREMENTS): New.
1625 (CI_ASSUMPTIONS): New.
1626 (TI_CONSTRAINT): New.
1628 (TI_REQUIREMENTS): New.
1629 (TI_ASSUMPTIONS): New.
1630 (DECL_TEMPLATE_CONSTRAINT): New.
1631 (CLASSTYPE_TEMPLATE_CONSTRAINT): New.
1632 (ENUM_TEMPLATE_CONSTRAINT): New.
1633 (TEMPLATE_TEMPLATE_PARM_TEMPLATE_CONSTRAINT): New.
1634 (TYPE_TEMPLATE_CONSTRAINT): New.
1635 (cp_tree_node_structure_enum): Added entry for constraint info.
1636 (lang_tree_node): Added entry for constraint info.
1637 (lang_decl_base): Added bit for concept declarations.
1638 (DECL_DECLARED_CONCEPT_P): New.
1639 (cp_decl_spec): Added ds_concept declaration specifier.
1640 * gcc/cp/Make-lang.in (logic.o): New target.
1641 * gcc/cp/semantics.c (finish_template_requirements): Rewrite.
1642 * gcc/cp/logic.cc: New
1643 * gcc/cp-tree.def (CONSTRAINT_INFO): New node.
1644 * gcc/cp/pt.c (current_template_args): Make non-static.
1645 (redeclare_class_template): Take constraints as a 3rd argument
1647 2013-04-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1649 * gcc/cp/Make-lang.in: Add constraints.o target.
1650 * gcc/cp/cp-tree.h (substitute_template_parameters): Declare.
1651 (instantiate_requirements): Declare.
1652 (conjoin_requirements): Declare.
1653 (disjoin_requirements): Declare.
1654 (reduce_requirements): Declare.
1655 * gcc/cp/pt.c (substitute_template_parameters): Define.
1656 (instantiate_requirements): Define.
1657 * gcc/cp/pt.c (finish_template_requirements): Call
1658 reduce_requirements to get constraints.
1659 * gcc/cp/parser.c (cp_parser_type_parameter): Restore saved
1660 constraints after parsing template template parameter decl.
1661 * gcc/cp/constraints.cc: New.
1663 2013-03-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1665 * gcc/cp/Make-lang.in: Add constraint.c
1666 * gcc/cp/constraint.c: New
1667 (conjoin_requirements): New
1668 (disjoin_requirements): New
1669 (requirement_reduction): New class
1670 (reduce_requirements): New
1671 * gcc/cp/cp-tree.h (reduce_requrements): New
1672 (conjoin_requirements): New
1673 (disjoin_requirements): New
1674 * gcc/cp/cp-tree.h (finish_template_template_parm) Comments.
1675 * gcc/cp/semantics.c (finish_template_requirements) Start
1676 working with requirements.
1679 2013-03-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1681 * gcc/cp/cp-tree.h (saved_scope): Add template requirements.
1682 (finish_template_requirements): Declare
1683 * gcc/cp/parser.c (cp_parser_template_requirement_opt): Declare.
1684 (cp_parser_template_declaration): Document grammar extensions.
1685 (cp_parser_type_parameter): Parse requirements for template
1686 template parameters.
1687 (cp_parser_member_declaration): Parse requirements for
1688 members of class templates.
1689 (cp_parser_template_requirement_opt): Define.
1690 (cp_parser_template_declaration_after_exp): Parse requirements
1691 for template declarations.
1692 * gcc/cp/semantics.c (finish_template_requirements): Define.
1693 * gcc/cp/lex.c (cxx_init): Enable concepts by default.
1695 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
1697 * lex.c (flag_concepts): Revert left over declaration.
1699 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
1701 * gcc/c-family/c-common.c (cxx_dialect): Set C++11 as default.
1702 * gcc/c-family/c.opt(flag_concepts): Add.
1703 * gcc/cp/lex.c (flag_concepts): New. Enabled concept support by
1706 2013-02-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1708 * gcc/c-family/c-common.h (rid): New resreserved words for concepts.
1709 * gcc/c-family/c-common.c (c_common_reswords): Definitions thereof.
1710 * gcc/doc/extend.texi (write_symbol): Initial concept docs.