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