1 2015-03-03 Andrew Sutton <andrew.n.sutton@gmail.com>
3 Rewrite to use new constraint model.
4 * gcc/cp/call.c (add_function_candidate): Use new constraint
6 (build_new_function_call): Evaluate concepts when selected
7 by overload resolution.
8 * gcc/cp/class.c (resolve_address_of_overloaded_function):
9 Use new constraint interface.
10 * gcc/cp/constexpr.c (cxx_eval_constant_expression): Don't
11 try to constexpr evaluate a requires-expression.
12 (potential_constant_expression_1): Stop using old
13 requires/constraint features.
14 gcc/cp/constraint.cc: Much rewriting, reorganization, refactoring
15 to support new constraint/requirement terms.
16 (lift_function_definition): New. Factor lifting code out of
17 lift_call for reuse in evaluate_function_concept.
18 (lift_variable_intializer): New. Factor lifting code out of
19 lift_var for reuse in evaluate_variable_concept.
20 (lift_template_id): Restore checking code for mis-written
22 (lift_requires_expr): Handle these separately.
23 (xform_*_requirement): New. Transform requires-expressions
25 (get/set/remove_constraints, decl_constraints): Move to
26 pt.c to allow for garbage collection.
27 (processing_constraint): Kill this global.
28 (diagnose_*): Update diagnostics to use the new constraint
30 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Remove typing
32 * gcc/cp/cp-tree.def: Add new nodes for requirements and
33 constraints. Remove previous constraint/req nodes.
34 gcc/cp/cp-tree.h (COMPOUND_REQ_NOEXCEPT_P): New.
35 (ICONV_CONSTR_EXPR, ICONV_CONSTR_TYPE): Fix operands.
36 (constraint_p, make_predicate_constraint_p, valid_constraints_p): New.
37 (misc): Remove unused declarations.
38 gcc/cp/cxx-pretty-print.c: Reorganize/rewrite for new constraint
40 (primary_expression, expression): Remove unused nodes, add options
42 gcc/cp/cxx-pretty-print.h: Declare new functions for pretty
44 gcc/cp/decl.c (duplicate_decls): Only reclaim when flag_concepts
46 (grokfndecl): Associate predicate constraints.
47 gcc/cp/decl2.c (mark_used): Don't instantiate concepts.
48 gcc/cp/error.c (dump_expr): Handle new constraints.
49 gcc/cp/method.c (implicitly_declare_fn): Use new constraint
51 gcc/cp/parser.c (make_call_declarator): Pass a requires-clause for
53 (cp_parser_type_name): Take a flag to indicate the presence of
54 a pre-parsed 'typename'.
55 (cp_parser_requires_expression): Move sentinel into function.
56 (cp_parser_type_requirement): Parse type requirements in accordance
58 (cp_parser_compound_requirement): Parse compound requirements in
59 accordance with Concepts TS. Remove constexpr requirements.
60 (cp_parser_template_declaration_after_export): Associate
61 predicate constraints.
62 gcc/cp/pt.c (get_template_for_ordering): New. Extract a template
63 decl from a list of candidates.
64 (lookup_template_class_1): Use new constraint interface.
65 (tsubst_pack_conjunction): Build an expression, not constraints.
66 (tsubst_decl): Only associate constraints when substituting
68 (tsubst): Kill subst rules for old nodes.
69 (most_specialized_partial_spec): Save candidates correctly
70 in the presence of constraints.
71 (always_instantiate_p): Never always instantiate a concept.
72 (type_dependent_expression_p): Requires expressions have type bool.
73 (decl_constraints): Moved from constraint.cc, use hash_table
75 gcc/cp/semantics.c (finish_call_expr): Remove constraints from
76 functions, not overload sets.
77 (finish_template_variable): Evaluate variable concepts by
78 determining satisfaction.
79 gcc/cp/typeck.c (cp_build_function_call_vec): Use new concept
81 gcc/cp/testsuite/g++.dg/concepts/*: Update tests to match syntax,
83 gcc/cp/testsuite/g++.dg/concepts/req1.C: Test requires-expression
86 2015-02-25 Braden Obrzut <admin@maniacsvault.net>
88 * gcc/cp/constraint.cc (lift_operands): New.
89 (lift_call): Lift operands on function calls and don't use
90 tsubst_constraint_expr.
91 (lift_var): Don't use tsubst_constraint_expr.
92 (lift_constraints): Use the returned number of operands for most nodes
93 and also lift from TREE_LISTs.
95 2015-02-17 Braden Obrzut <admin@maniacsvault.net>
97 * gcc/cp/constraint.cc (lift_call): Converted from normalize_call.
98 (lift_var): Converted from normalize_var.
99 (lift_template_id): Converted from normalize_template_id.
100 (lift_constraints): Implemented.
102 2015-02-16 Andrew Sutton <andrew.n.sutton@gmail.com>
104 * gcc/cp/cp-tree.h: (EXPR_CONSTR_EXPR, TYPE_CONSTR_TYPE): Fix
105 typos in macro names.
106 * gcc/cp/constraint.cc: (check_constraint*): New. Rewrite the
107 constraint checking implementation so that it matches the
108 wording and rules in n4377.
110 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
112 * gcc/cp/logic.cc: Rewrite to use new constraint model and
114 * gcc/cp/constraint.cc: Documentation and organization.
116 2015-02-10 Andrew Sutton <andrew.n.sutton@gmail.com>
118 * gcc/cp/cp-tree.h (is_constraint): Make static.
120 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
122 Rewrite normalization in terms of constraints.
123 * gcc/cp/cp-tree.h (is_constraint): New.
124 * gcc/cp/constraint.cc (normalize_*): Rewrite the previous normalization
125 model so that it conforms with the specification. Normalization applies
126 to constraints. Transformation of expressions into constraints now
127 happens in two phases: lifting concept definitions, and the actual
129 (tranform_expression, xform_*): New. Define transformation of
130 expressions into constraints.
131 (lift_constraints): New. Stubbed out inlining function.
133 2015-02-09 Andrew Sutton <andrew.n.sutton@gmail.com>
135 Start refactoring constraints to match the specification.
136 * gcc/cp/cp-tree.def: Add new TREECODEs for constraints.
137 * gcc/cp/cp-tree.h: Add accessor macros for constraint operands.
139 2015-02-05 Braden Obrzut <admin@maniacsvault.net>
141 * gcc/cp/constexpr.c (potential_constant_expression_1): Readded missing
142 cases from previous merge from trunk.
143 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Restored
144 CPTK_IS_CONVERTIBLE_TO for the time being since the constraint code
146 * gcc/cp/semantics.c (finish_trait_expr): Likewise.
147 * gcc/testsuite/g++.dg/concepts/req9.C: New test.
149 2015-02-03 Braden Obrzut <admin@maniacsvault.net>
151 * gcc/cp/class.c (build_clone): Clone constraints.
152 * gcc/cp/constraint.cc (normalize_atom): Update diagnostic.
153 (normalize_constraints): Return error_mark_node if normalization fails.
154 (get_constraints): Access constraints through hash map.
155 (set_constraints): Set constraints through hash map.
156 (remove_constraints): Access constraints through hash map.
157 (associate_classtype_constraints): New.
158 (init_leading_requirements): Removed.
159 (init_trailing_requirements): Removed.
160 (update_leadng_requirements): Removed.
161 (update_trailing_requirements): Removed.
162 (save_leading_constraints): Removed.
163 (save_trailing_constraints): Removed.
164 (finish_template_constraints): Removed.
165 (build_constraints): New. Builds CONSTRAINT_INFO from requirements.
166 (finish_concept_introduction): Check generated parameters for errors.
167 (tsubst_constraint_info): Update implementation.
168 (equivalent_constraints): Check input types.
169 (subsumes_constraints): Update implementation.
170 (at_least_as_constrained): New. Check if a decl's constraints subsumes
172 (diagnose_constraints): Temporarily simplify diagnostics.
173 * gcc/cp/cp-tree.h (tree_constraint_info): Refactor the way constraints
175 (CI_TEMPLATE_REQS): Renamed from CI_LEADING_REQS.
176 (CI_DECLARATOR_REQS): Renamed from CI_TRAILING_REQS.
177 (CI_ASSOCIATED_CONSTRAINTS): New.
178 (CI_NORMALIZED_CONSTRAINTS): New.
179 (CI_ASSOCIATED_REQS): Removed.
180 (saved_scope): Save template requirements.
181 (current_template_reqs): Removed.
182 (lang_decl_min): Replace requires_clause (trailing requirements) with
183 more generic constraint_info.
184 * gcc/cp/cxx-pretty-print.c (cxx_pretty_printer::declarator): Print
186 (pp_cxx_function_definition): Moved requires clause printing to above.
187 (pp_cxx_init_declarator): Likewise.
188 (pp_cxx_template_declaration): Update implementation to get
189 requirements from CONSTRAINT_INFO.
190 * gcc/cp/decl.c (duplicate_decls): Remove constraints before reclaiming
192 (is_class_template_or_specialization): New.
193 (get_leading_constraints): Removed.
194 (adjust_fn_constraints): Removed.
195 (grokfndecl): Update implementation to other changes.
196 (get_trailing_requires_clause): New.
197 (grokdeclarator): Pass trailing requires clause to grokfndecl.
198 (xref_tag_1): Check overload constraints.
199 * gcc/cp/error.c (dump_template_decl): Print requires clause.
200 (dump_function_decl): Update implementation for accessing requirements.
201 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Update
202 CI_ASSOCIATED_REQS usage.
203 * gcc/cp/method.c (implicitly_declare_fn): Copy constraints of
204 inherited constructors.
205 * gcc/cp/parser.c (cp_parser_lambda_expression): Remove now unneeded
206 template requirements saving.
207 (cp_parser_type_parameter): Likewise.
208 (cp_parser_template_argument_list): Unwrap template_template_parms when
209 produced by short hand notation with function concepts.
210 (cp_parser_alias_declaration): Attach constraints to aliases.
211 (cp_manage_requirements): Removed.
212 (cp_parser_trailing_requirements_clause): Renamed from
213 cp_parser_trailing_requirements.
214 (cp_parser_init_declarator): Removed now unneeded requirements saving.
215 (cp_parser_basic_declarator): Separated from cp_parser_declarator.
216 (cp_parser_declarator): Parses trailing requires clause if
217 cp_parser_basic_declarator succeeds.
218 (cp_parser_class_specifier_1): Associate constaints with type.
219 (cp_parser_member_declaration): Remove unneeded template requirement
221 (cp_parser_template_declaration_after_export): Likewise.
222 (cp_parser_single_declaration): Associate constraints.
223 (cp_parser_late_parsing_for_member): Remove unneeded template
225 (synthesize_implicit_template_parm): Likewise.
226 * gcc/cp/pt.c (maybe_new_partial_specialization): Update
228 (process_template_parm): Removed unneeded template requirement saving.
229 (build_template_decl): Handle constraints.
230 (process_partial_specialization): Update constraint access and check
231 that specialization is more specialized.
232 (push_template_decl_real): Update constraint access.
233 (add_inherited_template_parms): Removed constraint handling.
234 (tsubst_pack_conjuction): Update implemenation.
235 (tsubst_decl): Changed constraint propagation.
236 (more_specialized_fn): Update constraint access.
237 (most_specialized_partial_spec): Update constraint access.
238 * gcc/cp/ptree.c (cxx_print_xnode): Update constraint access.
239 * gcc/cp/semantics.c (finish_call_expr): Remove constraints.
240 (finish_template_template_parm): Update constraint access.
241 * gcc/testsuite/g++.dg/concepts/alias4.C: Mark xfail.
242 * gcc/testsuite/g++.dg/concepts/class.C: Check for escape hatch.
243 * gcc/testsuite/g++.dg/concepts/class6.C: Added diagnostic.
244 * gcc/testsuite/g++.dg/concepts/inherit-ctor1.C: Improved test case.
245 * gcc/testsuite/g++.dg/concepts/inherit-ctor2.C: Updated diagnostic.
246 * gcc/testsuite/g++.dg/concepts/inherit-ctor4.C: Updated diagnostic.
247 * gcc/testsuite/g++.dg/concepts/intro4.C: Updated diagnostics.
248 * gcc/testsuite/g++.dg/concepts/req4.C: Updated diagnostic.
249 * gcc/testsuite/g++.dg/concepts/req5.C: Updated diagnostic.
251 2014-12-29 Jason Merrill <jason@redhat.com>
253 * gcc/cp/pt.c (type_dependent_expression_p): Remove obsolete use of
255 (convert_template_argument): Likewise.
257 2014-11-15 Braden Obrzut <admin@maniacsvault.net>
259 * gcc/cp/constraint.cc (resolve_constraint_check): Move definition
261 (normalize_template_id): Use expression location if available when
262 informing about missing parentheses.
263 (build_requires_expr): Added comment.
264 (diagnose_var): Clarified comment.
265 * gcc/cp/decl.c (check_concept_refinement): Remove outdated comment
266 regarding variable concepts.
267 (grokfndecl): Ensure that all concept declarations are definitions.
268 (grokdeclarator): Remove outdated comment regarding variable concepts.
269 * gcc/cp/parser.c (cp_parser_introduction_list): Use vec for temporary
270 list instead of a TREE_LIST.
271 (get_id_declarator): Renamed from cp_get_id_declarator.
272 (get_unqualified_id): Renamed from cp_get_identifier.
273 (is_constrained_parameter): Renamed from cp_is_constrained_parameter.
274 (cp_parser_check_constrained_type_parm): Renamed from
275 cp_check_constrained_type_parm.
276 (cp_parser_constrained_type_template_parm): Renamed from
277 cp_constrained_type_template_parm.
278 (cp_parser_constrained_template_template_parm): Renamed from
279 cp_constrained_template_template_parm.
280 (constrained_non_type_template_parm): Renamed from
281 cp_constrained_non_type_tmeplate_parm.
282 (finish_constrained_parameter): Renamed from
283 cp_finish_constrained_parameter.
284 (maybe_type_parameter): Renamed from cp_maybe_type_parameter.
285 (declares_type_parameter): Renamed from cp_declares_type_parameter.
286 (declares_type_template_parameter): Renamed from
287 cp_declares_type_template_parameter.
288 (declares_template_template_parameter): Renamed from
289 cp_declares_template_template_parameter.
290 (cp_parser_type_parameter): Call
291 cp_parser_default_type_template_argument and
292 cp_parser_default_template_template_argument which were already
293 factored out from this function.
294 (cp_maybe_constrained_type_specifier): Use the new INTRODUCED_PARM_DECL
295 instead of PLACEHOLDER_EXPR.
296 (cp_parser_requires_expr_scope): Remove old comment and change
297 destructor to use pop_bindings_and_leave_scope.
298 (cp_parser_requires_expression): Remove old comment.
299 (get_concept_from_constraint): Remove old comment.
300 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Changed expected
301 errors now that missing concept definitions are diagnosed earlier.
303 2014-11-11 Jason Merrill <jason@redhat.com>
305 * gcc/cp/call.c (add_function_candidate): Move constraint check after
308 * gcc/cp/class.c (get_member_fn_template)
309 (are_constrained_member_overloads): Remove.
310 (add_method): Call equivalently_constrained directly.
312 2014-11-03 Jason Merrill <jason@redhat.com>
314 * gcc/cp/parser.c (cp_parser_nonclass_name): Fix merge error.
316 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
318 Fixing user-reported issues and regressions
319 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
320 Only pop access checks on failed parsing.
321 * gcc/cp/pt.c (type_dependent_expr_p): Always treat a
322 requires-expr as if dependently typed. Otherwise, we try to
323 evaluate these expressions when they have dependent types.
324 * gcc/cp/constriant.cc (normalize_stmt_list): Remove unused
326 (normalize_call): Don't fold constraints during normalization.
327 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Update diagnostics.
329 2014-10-20 Andrew Sutton <andrew.n.sutton@gmail.com>
331 Fix another introduction regression.
332 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
333 Only pop access checks on failed parsing.
335 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
337 Fix regression related to concept introductions.
338 * gcc/cp/parser.c (cp_parser_template_declaration_after_exp):
339 Pop deferred access checks afer parsing the introduction.
341 2014-10-13 Andrew Sutton <andrew.n.sutton@gmail.com>
343 Fix bug related to cleanup expressions in concept definitions.
344 * gcc/cp/constraint.cc (check_function_concept): See through
345 cleanup handlers when checking the body of a function.
346 (normalize_cast): Removed. Handled in a default case.
347 (normalize_cleanup_point): New. Normalize the expression without
350 2014-09-25 Andrew Sutton <andrew.n.sutton@gmail.com>
352 Explicitly disallow function concepts with deduced return types.
353 * gcc/cp/constraint.cc (check_function_concept): Remove check
354 for deduced return type.
355 * gcc/cp/decl.c (check_concept_fn): Explicitly check for
357 * gcc/testsuite/g++.dg/concepts/fn-concept2.C: New.
359 2014-09-24 Andrew Sutton <andrew.n.sutton@gmail.com>
361 Check requirements on function concept definitions.
362 * gcc/cp/decl.c (finish_function): Check properties of a function
364 * gcc/cp/constraint.cc (check_function_concept): New. Check
365 for deduced return type and multiple statements.
366 (normalize_misc): Don't normalize multiple statements.
367 (normalize_stmt_list): Removed.
368 * gcc/cp/cp-tree.h (check_function_concept): New.
369 * gcc/testsuite/g++.dg/concepts/fn-concept1.C: New.
371 2014-09-04 Braden Obrzut <admin@maniacsvault.net>
373 Implement concept introductions.
374 * gcc/cp/constraint.cc (deduce_concept_introduction): New.
375 (build_concept_check): Allow arg to be NULL to skip placeholder.
376 (process_introduction_parm): New.
377 (finish_concept_introduction): New.
378 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Mark introduced parm.
379 * gcc/cp/cp-tree.def: New INTRODUCED_PARM_DECL.
380 * gcc/cp/parser.c (cp_parser_declaration): Tentatively parse for
381 concept introduction.
382 (cp_parser_introduction_list): New.
383 (cp_parser_member_declaration): Tentatively parse for concept
385 (cp_parser_template_introduction): New.
386 (cp_parser_template_declaration_after_export): Parse concept
388 * gcc/cp/pt.c (convert_template_argument): Treat INTRODUCED_PARM_DECL
390 (coerce_template_parms): If INTRODUCED_PARM_DECL represents a pack then
391 match the entire parameter pack of the template.
392 (type_dependent_expression_p): Treat INTRODUCED_PARM_DECL as a
394 * gcc/testsuite/g++.dg/concepts/introduction1.C: New.
395 * gcc/testsuite/g++.dg/concepts/introduction2.C: New.
396 * gcc/testsuite/g++.dg/concepts/introduction3.C: New.
397 * gcc/testsuite/g++.dg/concepts/introduction4.C: New.
398 * gcc/testsuite/g++.dg/concepts/introduction5.C: New.
400 2014-09-01 Andrew Sutton <andrew.n.sutton@gmail.com>
402 Fixing normalization in the presence of constructor calls.
403 * gcc/cp/constraint.cc (normalize_misc): Handle constructor
405 * gcc/testsuite/g++.dg/concepts/req7.C: New.
407 2014-08-29 Andrew Sutton <andrew.n.sutton@gmail.com>
409 Fixing partial-template-id bug.
410 * gcc/cp/parser.c (cp_parser_type_name): If the returned type-decl
411 is actually a shorthand declaration, don't simulate an error.
412 * gcc/testsuite/g++.dg/concepts/template-parm10.C: New.
414 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
416 Add tests for constrained friends.
417 * gcc/testsuite/g++.dg/concepts/friend1.C: New.
418 * gcc/testsuite/g++.dg/concepts/friend2.C: New.
420 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
422 * gcc/cp/decl.c (is_concept_var): Coding style fix.
424 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
426 Fixing regression in scoping rules for templates.
427 * gcc/cp/semantics.c (fixup_tmeplate_type): Lift check to
428 finish_template_type.
429 (finish_template_type): Only do this when concepts are enabled,
430 and also when the class is actually a template. For non-dependent
431 types there are no actions to be taken.
433 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
435 Additional declaration restrictions on variable concepts.
436 * gcc/cp/decl.c (is_concept_var): New.
437 (cp_finish_decl): Check for uninitialized variable
439 (grokvardecl): Don't set the concept flag for non-template variables.
440 * g++.dg/concepts/decl-diagnose.C: Add tests.
442 2014-08-19 Ville Voutilainen <ville.voutilainen@gmail.com>
444 Ban static member function concepts.
445 * gcc/cp/decl.c (grokdeclarator): Diagnose static member function
447 * g++.dg/concepts/decl-diagnose.C: Adjust.
448 * g++.dg/concepts/mem-concept-err.C: Adjust.
449 * g++.dg/concepts/mem-concept.C: Adjust.
451 2014-08-15 Andrew Sutton <andrew.n.sutton@gmail.com>
453 Fixes to variable concept implementation.
454 * gcc/cp/cp-tree.h (variable_concept_p): New.
455 * gcc/cp/parser.c (cp_parser_nonclass_name): Check for concepts,
457 * gcc/cp/decl.c (grokvardecl): Label concepts as concepts.
458 * gcc/cp/constraint.cc (check_call): New.
459 (normalize_call): Ensure that calls are probably to functions.
460 (normalize_template_id): Update diagnostics.
461 (finish_template_constraints): Mark assumptions as an error if
462 constraint normalization fails. This was causing normalization
463 to be run twice during the construction of a single declaration.
464 * gcc/testsuite/g++.dg/concepts: Update tests.
466 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
469 * gcc/cp/pt.c (value_dependent_expression_p): Don't assume
470 that all nodes have operands.
472 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
474 Implement normalization checks.
475 * gcc/cp/constraint.cc (normalize_expr): Delegate cast and
476 atomic nodes to a dedicated function.
477 (check_logical): Check that an && or || does not resolve to a
478 user-defined function.
479 (normalize_logical): Check operators and save the locaiton of
481 (normalize_call, normalize_var): Remove spurios error messages.
482 (normalize_cast): New, delegates to normalize atom.
483 (normalize_atom): Check that instantiated expressions can be
485 (tsubst_constraint_info): Re-normalize the associated constraints
486 to check for post-substitution restrictions.
487 * gcc/cp/cp-tree.h (xvalue_result_type): Add to header.
489 2014-08-14 Andrew Sutton <andrew.n.sutton@gmail.com>
491 * gcc/testsuite/g++.dg/concepts: Renamed ttp* to template-parm*,
494 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
496 * gcc/cp/class.c (resolve_address_of_overloaded_function): Check
498 * gcc/cp/decl.c (grokfndecl): For now, disallow constrained
499 non-template functions.
500 * gcc/testsuite/g++.dg/concepts: New tests.
502 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
504 * gcc/cp/parser.c (get_id_declarator, get_identifier): New helper
506 (cp_check_constrained_type_parm): Don't fail on null declarators.
507 (cp_finish_constrained_parameter): Remove redundant processing for
508 checking declarations.
509 (cp_maybe_type_parameter, cp_declares_type_parameter,
510 cp_declares_type_template_parameter,
511 cp_declares_template_template_parameter): New helper functions for
512 determining when a parameter declaration is actually a constrained
514 (cp_parser_default_type_template_argument,
515 cp_parser_default_template_template_argument): Parsing support
516 for argument types of default arguments.
517 (cp_parser_template_parameter): Finish constrained parameters
518 after all variadic and default arg checks.
519 (cp_parser_parameter_declaration): Parse default arguments
520 differently if the parameter actually declares a type parameter.
521 * gcc/testsuite/g++.dg/concepts: New tests.
523 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
525 * gcc/testsuite/g++.dg/concepts/explicit-spec6.C: New test.
527 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
529 Fix regression in bootstrap.
530 * gcc/cp/call.c (get_temploid): Removed. No longer called.
531 (joust): Remove unused variable declarations.
533 2014-08-13 Andrew Sutton <andrew.n.sutton@gmail.com>
535 Implement deduction-based explicit instantiation and specialization.
536 * gcc/cp/call.c (joust): Allow all non-templates to be ordered by
538 * gcc/cp/pt.c (get_class_bindings): Remove superfluous parameter and
539 move constraint check into most_specialized_class.
540 (most_constrained_function): Order functions with the same signatures
541 by their constraints.
542 (determine_specialization): Candidates must satisfy constraints. Also,
543 order non-template candidates by constraints. Improve diagnostics
544 for instances where candidates are rejected.
545 (more_specialized_inst): New. Compare function templates.
546 (most_specialized_instantiation): Refactor to use
547 more_specialized_inst and order by constraints.
548 (most_specialized_class): Candidates must satisfy constraints.
549 * gcc/cp/decl.c (various) Cosmetic fixes.
550 (adjust_fn_constraints): Rewrite so that class template constraints
551 are not imposed on member function declarations.
552 * gcc/testsuite/g++.dg/concepts: New tests.
554 2014-08-13 Braden Obrzut <admin@maniacsvault.net>
556 * gcc/cp/constraint.cc (deduce_constrained_parameter): Deduce concept
557 from variable concept template-id expressions.
558 (normalize_var): New.
559 (normalize_template_id): Identify variable concepts.
560 (build_concept_check): Handle variable concepts.
561 (finish_shorthand_requirement): Handle variable concepts.
563 (diagnose_node): Identify variable concepts.
564 * gcc/cp/decl.c (grokvardecl): Pass concept flag through to
565 check_explicit_specialization.
566 (grokdeclarator): Allow variable concepts and pass concept flag through
568 * gcc/cp/parser.c (cp_is_constrained_parameter): Accept variable
570 (cp_parser_nonclass_name): Accept variable concepts.
571 (get_concept_from_constraint): Handle variable concepts.
572 * gcc/cp/pt.c (tsubst_copy_and_build): Lookup variable templates.
573 (value_dependent_expression_p): Check requires expressions for value
575 * gcc/cp/semantics.c (finish_call_expr): Don't instantiate variable
576 templates if processing a template declaration.
577 * gcc/testsuite/g++.dg/concepts/decl-diagnose.C: Change expected error
578 as variable concepts are now handled.
579 * gcc/testsuite/g++.dg/concepts/var-concepts1.C: New test.
580 * gcc/testsuite/g++.dg/concepts/var-concepts2.C: New test.
582 2014-08-11 Andrew Sutton <andrew.n.sutton@gmail.com>
584 * gcc/cp/pt.c (tsubst): Don't short circuit substitution into
585 types when processing constraints. Also, avoid asserting when
586 substituting into template parameters.
587 * gcc/cp/constraint.c (tsubst_constraint_expr): Indicate that
588 constraint processing is happening.
589 (tsubst_constraint_info): Just substitute directly into the
590 normalized constraints instead of re-normalizing.
591 (diagnose_constraints): Adjust template arguments when
592 diagnosing template constraint failures.
593 * gcc/cp/logic.cc (decompose_assumptions): Handle null assumptions.
595 2014-08-08 Andrew Sutton <andrew.n.sutton@gmail.com>
597 * gcc/cp/logic.cc (subsumes_constraints_nonnull): Don't re-normalize
598 constraints, it's already been done.
599 * gcc/cp/cp-tree.h (*_requirement[s]): Renamed to *_constraint[s] to
600 reflect wording in specification. Removed reduce_requirements.
601 * gcc/cp/pt.c (process_template_parm, tsubst_pack_conjunction): Update
603 (fn_type_unification): Remove constraint check.
604 * gcc/cp/parser.c (cp_parser_type_parameter,
605 cp_parser_trailing_requirements,
606 cp_parser_template_declaration_after_export,
607 synthesize_implicit_template_parm): Update from renaming.
608 * gcc/cp/constraint.cc: Renamed a lot of functions to reflect wording
610 (finish_template_constraints): Normalize associated constraints.
611 (tsubst_constraint_expr): Renamed from instantiate_requirements.
612 Normalize associated constraints.
613 (check_satisfied): Return true if the arguments refer to template
615 (all_constraints_satisfied, any_conjunctions_satisfied,
616 check_requirements): No longer needed.
617 (check_diagnostic_constraints): Just normalize the expression, don't
620 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
622 * gcc/testsuite/g++.dg/concepts/concepts.exp: Add missing argument
625 2014-08-06 Andrew Sutton <andrew.n.sutton@gmail.com>
627 * gcc/cp/constraints.c (tsubst_requires_body, instantiate_requirements):
628 Lift the unevaluated operand guard to the entire constraint expression.
629 (check_satisfied, all_constraints_satisfied,
630 any_conjunctions_satisfied): Rewrite constraint checking to use
631 atomic constraints. Prevents instantiation of concepts.
632 (check_diagnostic_constraints): Recursively decompose and check
633 constraints for fine-grain diagnostics.
634 (diagnose_*): Use new constraint checking function.
637 2014-07-30 Braden Obrzut <admin@maniacsvault.net>
639 * gcc/cp/parser.c (cp_parser_trailing_requirements): Handle requires
640 keyword manually so that we can push function parameters back into
642 * gcc/cp/decl.c (push_function_parms): New. Recovers and reopens
643 function parameter scope from declarator.
644 * gcc/testsuite/g++.dg/concepts/req*.C: New tests.
646 2014-07-30 Andrew Sutton <andrew.n.sutton@gmail.com>
648 * gcc/testsuite/g++.dg/concepts/test.C: Removed.
650 2014-07-28 Andrew Sutton <andrew.n.sutton@gmail.com>
652 * gcc/cp/cp-tree.h (more_constraints): Remove
653 (subsumes_constraints): Renamed from more_constraints
654 (more_constrained): Repurposed
655 * gcc/cp/call-c (template_decl_for_candidates): Rename to get_temploid,
656 only get template info for member functions of a class template
658 (joust): Handle member functions of class template specializations
659 separately from function templates. This matches the new wording in
661 * gcc/cp/logic.cc (match_terms): Make inline.
662 (subsumes_constraints): Rename to subsumes_constraints_nonnull.
663 * gcc/cp/pt.c (is_compatible_template_arg): Use subsumes.
664 (more_specialized_fn): Use usubsumes_constraints.
665 (more_specialized_class): Use more_constrained.
666 * gcc/cp/constraint.cc (more_constraints): Removed.
667 (more_constrained): New.
669 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
671 * gcc/cp/typeck.c (cp_build_function_call_vec): Emit diagnostic
672 at the input location.
673 * gcc/cp/error.c (dump_template_decl): Constraints are never invalid
674 in this way. Also fixes brace warning.
676 2014-07-11 Andrew Sutton <andrew.n.sutton@gmail.com>
678 * gcc/cp/tree.c (cp_tree_equal): compare constraint infos by
679 their associated constraints (patch by Braden Obrzut).
680 * gcc/cp/logic.c (decompose_assumptions): Don't decompose errors.
681 (subsumes_constraints): Update to use new macros.
682 * gcc/cp/cp-tree.h (tree_constraint_info): Rewrite constraints
683 to cache leading, trailing, and associated requirements.
684 (CI_SPELLING, CI_REQUIREMENTS): Remove
685 (CL_LEADING_REQS, CI_TRAILING_REQS, CI_ASSOCIATED_REQS): New
686 accessors for constraint info field.
687 (save_leading_requirements, save_trailing_requirements,
688 valid_template_requirements_p): New.
689 (make_constraints): Removed.
690 (instantiate_requirements): Add flag to substitute in either
691 dependent/non-dependent mode.
692 (tsubst_constraint_info): New.
693 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_clause): New.
694 * gcc/cp/cxx-pretty-print.c (pp_cxx_init_declarator): Remove.
695 (pp_cxx_function_definition): Print trailing constraints if they
697 (pp_cxx_init_declarator): New. Print trailing requirements.
698 (pp_cxx_template_declaration): Print leading requirements.
699 (pp_cxx_requires_clause): New.
700 * gcc/cp/pt.c (build_template_decl): Ensure completion of constraints
701 when associating them with the template.
702 (add_inherited_template_parms): Update to new constraint mechanisms.
703 (redeclare_class_template): Update to new constraint mechanisms.
704 (tsubst_decl): Update to new constraint mechanism.
705 * gcc/cp/parser.c (cp_parser_lambda_expression): Save off constraints
707 (cp_check_constrained_type_parm): Save leading requirements instead
709 (cp_parser_trailing_requirements): Simplify by just saving the trailing
711 (cp_parser_init_declarator): Save off constraints before parsing the
713 (cp_parser_member_declaration): Save off requirements before parsing
715 (cp_parser_requires_clause): Defer constexpr check until as late as
717 (cp_parser_template_declaration_after_export): Save leading requirements
718 instead of finishing them.
719 (synthesize_implicit_template_parm): Save leading requirements when
720 processing a constrained-type-specifier.
721 * gcc/cp/class.c (get_member_fn_template): Update to use new constraint
723 * gcc/cp/call.c (constraint_failure): Renamed from
724 template_constraint_failure. Produce reasons for non-template functions.
725 (is_constrainable_non_template_fn): Removed.
726 (add_function_candidate): Use new constraint association framework.
727 * gcc/cp/ptree.c (cxx_print_xnode): Dump leading, trailing requirements.
728 * gcc/cp/error.c (dumpl_template_decl): Print a leading requires-clause.
729 (dump_function_decl): Print a trailing requires-clause.
730 * gcc/cp/semantics.c (finish_template_template_parm): Finish
731 template constraints before associating them.
732 * gcc/cp/constraint.cc (reduce_call): Don't fold constants when
734 (reduce_template_id): Replace EXPR_LOCATION in diagnostics. Return
735 error_mark_node instead of corrected call expression.
736 (reduce_requirements): Don't normalize a null expression.
737 (make_constraints): Removed.
738 (get_constraints): Updated.
739 (set_constraint): Updated.
740 (get_shorthand_requirements): Use the appropriate macro.
741 (build_constraint_info, init_leading_requirements,
742 init_trailing_requirements, update_leadng_requirements,
743 update_trailing_requirements, save_leading_requirements,
744 save_trailing_requirements): New.
745 (finish_template_requirements): Analyze and decompose constraints.
746 (valid_template_requirements_p): New.
747 (instantiate_requirements): New flag.
748 (tsubst_constraint_info): New.
749 (check_requirements): Update.
750 (check_constraints): Add another round of instantiation to ensure
751 that all non-constexpr exprs are folded out of the expression.
752 (check_constraints): Update.
753 (equivalent_constraints): Redefine constraint equivalence in terms
754 of tokens (patch by Braden Obrzut).
755 (diagnose_trait, diagnose_check, diagnose_requires,
756 diagnose_constraints): Update.
757 * gcc/cp/decl2.c (check_classfn): Update constraint mechanisms.
758 * gcc/cp/decl.c (decls_match): Update to use new constraints.
759 (duplicate_decls): members match if they have equivalent constraints.
760 (get_leading_template_requirements): New.
761 (adjust_out_of_class_fn_requirements): New.
762 (grokfndecl): Associate requirements with a function declaration.
763 * gcc/testsuite/g++.dg/concepts/*: New tests.
765 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
767 * gcc/c-family/c.opt (flag_concepts): Don't enable by default.
768 * gcc/c-family/c-opts.c (set_std_cxx1z): Enable concepts if
769 -std=cxx1z is selected.
770 * gcc/c-family/c-format.c (gcc_cxxdia): Add "Z" as format specifier.
771 * gcc/cp/c-common.c (cxx_dialect): Make -std=c++98 the default
773 * gcc/cp/lex.c (cxx_init): Don't set flag_concepts explicitly.
774 * gcc/testsuite/g++.dg/concepts/*.C: Update build flags.
776 2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
778 * gcc/cp/cp-tree.h (DECL_CONSTRAINTS): Remove this macro; use
779 get_constraints instead.
780 (set_constraints): new.
781 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Use
783 * gcc/cp/pt.c (get_specialization_constraints): Use get_constraints.
784 (build_template_decl): Use get_constraints.
785 (process_partial_specialization): Use get_constraints.
786 (add_inherited_template_parms): Use get_constraints.
787 (redeclare_class_template): Use get_constraints.
788 (is_compatible_template_arg): Use get_constraints.
789 (tsubst_friend_class): Use get_constraints.
790 (tsubst_decl): Uset get_constraints.
791 * gcc/cp/semantics.c (finish_template_template_parm): Use
793 (fixup_template_type): Use get_constraints.
794 * gcc/cp/constraint.cc (constraints): New global association
795 of declarations to constraints.
796 (get_constraints): Return the associated constraints from the
798 (set_constraints): New. Associate constraints with a declaration.
799 (check_template_constraints): Use get_constraints.
800 (equivalently_constrained): Use get_constraints.
801 (more_constrained): Use get_constraints.
802 (diagnose_constraints): Use get_constraints.
803 * gcc/testsuite/g++.dg/concepts/partial-spec.C: New.
805 2014-06-25 Andrew Sutton <andrew.n.sutton@gmail.com>
807 * gcc/cp/parser.c (cp_parser_requires_clause): Don't fold expressions
808 when parsing a requires-clause.
809 * gcc/cp/constraint.cc (reduce_requirements): Don't fold
810 expressions during constraint normalization.
812 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
814 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): Defer
815 handling the BASELINK check until concept-resolution in order to
816 allow member conceps.
817 (cp_parser_nonclass_name): Also Check for concept-names when the
818 lookup finds a BASELINk.
819 * gcc/cp/constraint.cc: (resolve_constraint_check) If the call
820 target is a base-link, resolve against its overload set.
821 (build_concept_check): Update comments and variable names to
822 reflect actual processing.
823 * gcc/testuite/g++.dg/concepts/mem-concept.C: New test.
824 * gcc/testuite/g++.dg/concepts/mem-concept-err.C: New test.
826 2014-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
828 * gcc/cp/error.c (dump_expr): Pretty print placeholder to improve
831 2014-06-17 Braden Obrzut <admin@maniacsvault.net>
833 * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): If getting
834 a baselink, use the referred-to function/overload declarations rather
837 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
839 * gcc/cp/constraint.cc (deduce_constrained_parameter): Refactor
840 common deduction framework into separate function.
841 (build_call_check): New.
842 (build_concept_check): Take additional arguments to support the
843 creation of constrained-type-specifiers from partial-concept-ids.
844 (build_constrained_parameter): Take arguments from a partial-concept-id.
845 * gcc/cp/cp-tree.h (build_concept_check, biuld_constrained_parameter):
846 Take a template argument list, defaulting to NULL_TREE.
847 * gcc/cp/parser.c (cp_parser_template_id): Check to see if a
848 template-id is a concept check.
849 (cp_check_type_concept): Reorder arguments
850 (cp_parser_allows_constrained_type_specifier): New. Check contexts
851 where a constrained-type-specifier is allowed.
852 (cp_maybe_constrained_type_specifier): New. Refactored common rules
853 for concept name checks.
854 (cp_maybe_partial_concept_id): New. Check for
855 constrained-type-specifiers.
856 * gcc/testuite/g++.dg/concepts/partial.C: New tests.
857 * gcc/testuite/g++.dg/concepts/partial-err.C: New tests.
858 * gcc/testuite/g++.dg/concepts/concepts.exp: Add missing test driver.
860 2014-06-12 Andrew Sutton <andrew.n.sutton@gmail.com>
862 * gcc/cp/parser.c (cp_check_type_concept): New.
863 (cp_check_concept_name): Remove redundant condition from check.
864 Diagnose misuse of non-type concepts in constrained type specifiers.
865 * gcc/testuite/g++.dg/concepts/generic-fn.C: Add tests for
866 non-simple constrained-type-specifiers and nested-name-specifiers
868 * gcc/testuite/g++.dg/concepts/generic-fn-err.C: New tests for
869 diagnosing ill-formed programs.
871 2014-06-11 Andrew Sutton <andrew.n.sutton@gmail.com>
873 * gcc/cp/cp-tree.h (build_constrained_parameter): Renamed fro
874 describe_tempalte_parm.
875 * gcc/cp/parser.c (cp_check_constrained_type_parm): New. Prevent
876 declaration of cv-qualifed or non-id types.
877 (cp_constrained_type_template_parm): Renamed, check for invalid
879 (cp_constrained_template_template_parm): Renamed, check for invalid
881 (cp_constrained_non_type_tmeplate_parm): Renamed.
882 (cp_finish_constrained-parameter): Support checking of decarlarations.
883 (cp_check_concept_name): Renamed. Add initial support for auto
884 and constrained-type-specifiers in compound requirements.
885 (cp_parser_nonclass_name): Only check for concept names if -fconcepts
887 (cp_manage_requirements): New RAII guard for managinging the
888 current_template_reqs variable during declaration parsing.
889 (cp_paresr_trailing_requirements): Refactored common parsing
890 requirements from cp_parser_init_declarator and
891 cp_parser_member_declarator. Take terse constraints from implicit
892 parameter declarations.
893 (cp_parser_init_declarator): Cleanup, refactor requirement logic.
894 (cp_parser_type_id_1): Allow auto in compound requirements.
895 (cp_parser_member_declaration): Cleanup, refactor requirement logic.
896 (cp_parser_compound_requirement): Note parsing state for the
897 trailing-type-id so we can get auto and constrained-type-specifiers.
898 (cp_parser_function_definition_after_decl): Remove broken constraint
900 * gcc/cp/parser.h (cp_parser): New member.
901 * gcc/cp/constraint.cc (finish_validtype_expr): Initial (non-)handling
902 of auto in type requirements.
903 (finish_concept_name): Moved to cp_check_concept_name.
904 * gcc/testuite/g++.dg/concepts/constrained-parm.C: New test.
905 * gcc/testuite/g++.dg/concepts/generic-fn.C: New test.
908 2014-03-10 Andrew Sutton <andrew.n.sutton@gmail.com>
910 * gcc/testuite/g++.dg/concepts/fn1.C: New test.
911 * gcc/testuite/g++.dg/concepts/fn2.C: New test.
913 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
915 * gcc/cp/parser.c (synthesize_implicit_template_parm): Allow concepts
916 to declare implicit template parameters. Only synthesize new parameters
917 if the concept name is new.
918 (finish_concept_name): Moving into parser.c for the time being. Needs
919 to be rewritten to remove duplicate code between parser.c and
922 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
924 * gcc/cp/pt.c (tsubst_copy): Expand pack expansions as conjunctions.
926 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
928 * gcc/cp/pt.c (tsubst_pack_conjunction): Don't try to conjoin
929 dependent expressions.
931 2013-11-012 Andrew Sutton <andrew.n.sutton@gmail.com>
933 * gcc/cp/semantics.c (fixup_template_type): Compare primary template
934 types to specializations using structural types so we don't run into
935 canonical type errors with constrained specializations.
937 2013-11-08 Andrew Sutton <andrew.n.sutton@gmail.com>
939 * gcc/cp/pt.c (add_inherited_template_parms): Instantiate requirements
940 in a processing template decl context.
942 2013-11-05 Andrew Sutton <andrew.n.sutton@gmail.com>
944 * gcc/cp/semantics.c (fixup_template_type): Add a same-type check
945 for specialiations so we don't accidentally match non-dependent
946 specializations having a different type.
948 2013-10-26 Ville Voutilainen <ville.voutilainen@gmail.com>
950 * gcc/cp/decl.c (grokdeclarator): Reject concept keyword
951 in typedefs, function parameters, data members, non-static
952 member functions and variables. Allow static member functions
955 2013-10-30 Andrew Sutton <andrew.n.sutton@gmail.com>
957 * gcc/cp/semantics.c (fixup_template_type): Don't emit errors when
958 no templates can be found with matching constraints.
960 2013-10-25 Andrew Sutton <andrew.n.sutton@gmail.com>
962 * gcc/cp/parsre.c (cp_parser_requires_expression): Gracefully
963 fail when parsing a requires expr outside a template.
965 2013-10-24 Andrew Sutton <andrew.n.sutton@gmail.com>
967 * gcc/cp/c-common.c (c_common_r): Remove unused keywords "assume",
968 "axiom", and "forall".
969 * gcc/cp/c-common.h (rid): Removed unused reserved word ids.
971 2013-10-24 Edward Smith-Rowland <3dw4rd@verizon.net>
973 * gcc/cp/typeck.c (cp_build_function_call_vec): Use unused variable
976 2013-10-23 Andrew Sutton <andrew.n.sutton@gmail.com>
978 * gcc/cp/class.c (get_member_fntemplate): New.
979 (are_constrained_member_overloads): Only get a template declaration
980 if the member function is, in fact, a template or temploid.
981 * gcc/cp/pt.c (check_explicit_specialization): Do not allow
982 explicit specializations to be declared 'concept', and do not allow
983 an explicit specialization of a concept.
984 * gcc/cp/decl.c (grokfndecl): Propagate the concept flag to
985 check_explicit_specialization.
987 2013-10-22 Andrew Sutton <andrew.n.sutton@gmail.com>
989 * gcc/c-family/c-common.c (cxx_dialect): Make the default
991 * gcc/cp/constraint.cc (check_constrained_friend): Don't assert
994 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
996 * gcc/cp/logic.cc (left_requires), (decompose_left): Add
997 decomposition rules for requires expressions.
998 (subsumes_requires), (subsumes_prop): Add subsumption rules for
999 requires expressions.
1000 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failed conversion
1003 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1005 * gcc/cp/constraint.cc (finish_concept_name): Allow functions with
1006 the same name as concepts to resolve as call expressions in the
1009 2013-10-16 Andrew Sutton <andrew.n.sutton@gmail.com>
1011 * gcc/cp/constraint.cc (conjoin_requiremens): New.
1012 (resolve_constraint_check): Filter non-concept candidates before
1013 coercing arguments. Perform deduction in a template-decl processing
1014 context to prevent errors during diagnosis.
1015 (finish_concept_name), (finish_shorthand_requirement),
1016 (get_shorthand_requirements): New.
1017 * gcc/cp/pt.c (template_parm_to_arg): Make non-static.
1018 (process_templat_parm): Build shorthand requirements from the
1019 parameter description.
1020 (end_templat_parm_list): New.
1021 (convert_placeholder_argument): New.
1022 (convert_template_argument): Match placeholder arguments against
1023 any template parameter.
1024 (tsubst_pack_conjuction): New.
1025 (tsubst_expr): Expand a pack as a conjunction.
1026 (type_dependent_expression_p): Placeholders are always type
1028 * gcc/cp/parser.c (cp_is_constrained_parameter),
1029 (cp_finish_template_type_parm), (cp_finish_template_template_parm)
1030 (cp_finish_non_type_template_parm), (cp_finish_constrined_parameter):
1032 (cp_parser_template_parameter): Handle constrained parameters.
1033 (cp_parser_nonclass_name): An identifier naming an overload set
1034 may declare a constrained parameter.
1035 (cp_parser_type_parameter), (cp_parser_template_declaration_after_exp):
1036 Get shorthand requirements from the tmeplate parameter list.
1037 * gcc/cp/cp-tree.h (TEMPLATE_PARM_CONSTRAINTS): New.
1039 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1041 * gcc/cp/cp-tree.h (check_constrained_friend): Take requirements as
1043 * gcc/cp/constraints.cc (check_constrained_friend): Do not diagnose
1044 errors in unconstrained friend declarations.
1045 * gcc/cp/parser.cc (cp_parser_member_declaration): Pass current
1046 requirements to check_constrained_friend.
1048 2013-10-07 Andrew Sutton <andrew.n.sutton@gmail.com>
1050 * gcc/cp/parser.c (cp_parser_member_declaration): Check that
1051 a constrained friend definition is valid.
1052 * gcc/cp/decl.c (grokfndecl): Disallow constrained friend template
1054 * gcc/cp/constraints.cc (check_constrained_friend): New.
1055 * gcc/cp/typeck.c (cp_build_function_call_vec): Diagnose constraints
1056 in the presence of the failure of a single candidate.
1057 * gcc/cp/cp-tree.h (check_constrained_friend): New.
1058 * gcc/cp/call.c (is_non_template_member_fn): Make inline.
1059 (is_non_template_friend), (is_constrainable_non_template_fn): New.
1060 (add_function_candidate): Predicate check on
1061 is_constrainable_non_template_fn.
1063 2013-09-10 Andrew Sutton <andrew.n.sutton@gmail.com>
1065 * gcc/cp/cp-tree.h (TEMPLATE_PARMS_CONSTRAINTS): New.
1066 * gcc/cp/parser.c (cp_parser_template_declaration_after_export),
1067 (cp_parser_type_parameter): Use TEMPLATE_PARMS_CONSTRAINTS.
1068 * gcc/cp/semantics.c (fixup_template_scope): Use
1069 TEMPLATE_PARMS_CONSTRAINTS.
1071 2013-09-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1073 * gcc/cp/cxx-pretty-print.c (pp_cxx_compound_requirement),
1074 (pp_cxx_type_requirement), (pp_cxx_validtype_expr): Use
1075 pp->type_id() instead of pp_cxx_type_id().
1077 2013-09-09 Andrew Sutton <andrew.n.sutton@gmail.com>
1079 * gcc/cp/pt.c (get_class_bindings): Pass the partial specialization
1080 for constraint evaluation. Evaluate constraints, resulting in
1081 deduction failure on error.
1082 (get_specializaing_template_decl), (get_specialization_constraints),
1083 (maybe_new_partial_specialization): New.
1084 (maybe_process_partial_specialization): Allow the creation of
1085 new types for constrained partial specializations.
1086 (process_partial_specialization): Modify the canonical type
1087 of constrained partial specializations.
1088 (instantiate_class_template_1): Do not explicitly check constraints
1089 during class template instantiation.
1090 (tsubst_decl): Instantiate the constraints of template declarations.
1091 (more_specialized_class): Pass specializations to get_class_bindings().
1092 Compare specialization constraints if the types are equivalent.
1093 (most_specialized_class): Pass specialization to get_class_bndings().
1094 * gcc/cp/decl2.c (check_class_fn): Get the decl's requirements from
1095 either the current template reqs or from the template parameters.
1096 Allow overloading of constrained out-of-class member definitions.
1097 * gcc/cp/semantics.c (fixup_template_type): New. Match the template
1098 scope to a specialization with appropriate constraints.
1099 (finish_template_type): Fix template type when entering scope.
1100 * gcc/cp/parser.c (cp_parser_parse_type_parameter): Attach
1101 requirements to the current template parameter list.
1102 (cp_parser_init_declarator): Parse requires clauses for out-of-class
1103 member definitions. Be sure to restore current constraints before
1104 exiting the function.
1105 (cp_parser_member_declarator): Restore the previous requirements in
1106 an early-exit branch.
1107 (cp_parser_late_parsing_for_member): Restore constraints after
1108 maybe_end_member_template_processing().
1109 (cp_parser_template_declaration_after_exp): Attach constraints to
1110 the current template parameters.
1111 * gcc/cp/constraint.cc (reduce_template_id): Don't crash when
1112 omitting ()'s on constraint calls.
1113 (check_requirements): Don't evaluate dependent arguments.
1114 (check_constraints): Don't try to evaluate when arguments are
1116 (equivalent_constraints): Optimize the case when a and b are the
1119 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1121 * gcc/cp/semantics.c (trait_expr_value): Evaluate __is_same_as.
1122 (finish_trait_expr): Check __is_same_as and __is_convertible_to.
1123 * gcc/cp/constraint.cc (diagnose_trait): Diagnose failures in
1125 * gcc/cp/parser.c (cp_parser_primary_expression),
1126 (cp_parser_trait_expr): Parse __is_same_as.
1127 * gcc/cp/cp-tree.h (cp_trait_kind): Add CPTK_IS_SAME_AS.
1128 * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Pretty print
1131 2013-07-26 Andrew Sutton <andrew.n.sutton@gmail.com>
1133 * gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
1134 requires expr parameter list.
1136 2013-07-25 Andrew Sutton <andrew.n.sutton@gmail.com>
1138 * gcc/cp/parser.c (cp_parser_requires_expr): Update parser using new
1139 requires expression nodes. Renamed some grammar productions to better
1140 reflect the representation of the syntax. Create a new scope for
1141 requires parameters.
1142 (cp_parser_nested_requirement): Wrap results in a NESTED_REQ node.
1143 * gcc/cp/semantics.c (xvalue_result_type): New.
1144 (trait_expr_value): Evaluate __is_convertible_to.
1145 (finish_requires_expr): Implemented, along with other functions to
1146 construct and evaluate nodes for template constraints.
1147 (potential_constant_expression_1): Handle requires expressions.
1148 (finish_template_requirements), (finish_requires_expr), etc:
1149 Move to constraint.cc.
1150 * gcc/cp/cp-tree.def: (REQUIRES_EXPR), (EXPR_REQ), (TYPE_REQ),
1151 (NESTED_REQ), (VALIDEXPR_EXPR), (VALIDTYPE_EXPR), (CONSTEXPR_EXPR):
1153 * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Make new nodes typed.
1154 * gcc/cp/cp-tree.h (finish_expr_requirement),
1155 (finish_type_requirement), (finish_nested_requirement),
1156 (finish_validexpr_expr), (finish_validtype_expr),
1157 (finish_constexpr_expr): New.
1158 * gcc/cp/pt.c (convert_nontype_argument): Use can_convert_standard.
1159 (retrieve_local_specialization), (register_local_specialization),
1160 (extract_fnparm_pack): Make non-static.
1161 (tsubst_expr): Substitution rules for requires expressions.
1162 (instantiate_requirements): Move to constraints.cc
1163 (tsubst_constraint): Remove.
1164 * gcc/cp/call.c (can_convert): Allow user-defined conversions.
1165 (can_convert_standard): New.
1166 * gcc/cp/cvt.c (convert_to_reference): Use can_convert_standard.
1167 * gcc/cp/search.c (check_final_overrider): Use can_cnvert_standard.
1168 * gcc/cp/typeck.c (build_static_cast_1): Use can_convert_standard.
1169 * gcc/cp/error.c (dump_expr): Pretty print new nodes.
1170 * gcc/cp/cxx-pretty-print.c (pp_cxx_primary_expression): Pretty
1171 print new expr/req nodes.
1172 (pp_cxx_requires_expr): New along with related functions for
1173 pretty printing requirements.
1174 (pp_cxx_parameter_declaration_clause): Accommodate "raw" parameter
1175 lists in addition to function decls.
1176 (pp_cxx_requirement_parameter_list): Unified with parameter decl clause.
1177 * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_expr): New along with
1178 related functions for pretty printing requirements.
1179 * gcc/cp/logic.cc: Move header comments to top of file.
1180 * gcc/cp/constraint.cc (reduce_requirements): Handle requires
1182 (diagnose_constraints): Rename and handle requires expressions.
1184 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1186 * gcc/cp/error.c (cp_printer): Fix unnecessary whitespace change.
1187 * gcc/cp/constraint.cc (diagnose_node): Don't fail diagnosing
1190 2013-07-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1192 * gcc/cp/class.c (are_constrained_member_overloads): Fix doc typos.
1194 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1196 * gcc/cp/parser.c (cp_parser_init_declarator): Parse template
1197 requirements for out-of-class member definitions.
1198 * gcc/cp/decl2.c (check_classfn): Include match out-of-class
1199 definitions using constraints.
1200 * gcc/cp/constraint.cc (equivalently_constrained). Use get_constraints.
1201 (more_constrained). Use get_constraints.
1203 2013-06-24 Andrew Sutton <andrew.n.sutton@gmail.com>
1205 * gcc/cp/cp-tree.h (tree_template_info). Remove constraint from
1207 (check_template_info): Removed (unused).
1208 (TI_CONSTRAINT): Removed (no longer needed) along with related macros.
1209 (DECL_CONSTRAINTS): New. Get constraints from DECL_SIZE_UNIT for
1211 (build_template_info): Removed overload taking constraints.
1212 (get_constraints): Removed (no longer needed).
1213 * gcc/cp/class.c (are_constrained_member_overlaods): Allow constrained
1214 member function templates to be differentiated as overloads.
1215 * gcc/cp/decl.c (decls_match): Only compare constraints on
1217 (grokfndecl): Don't pass constraints to build_template_info.
1218 * gcc/cp/tree.c (bind_template_template_parm): Don't pass constraints
1219 to build_template_info.
1220 * gcc/cp/pt.c (build_template_info): Removed overload taking
1222 (check_explicit_specialization): Don't build new constraints for
1224 (build_template_decl): Pass constraints. Update docs.
1225 (process_partial_specialization): Stub out support for constrained
1226 partial specialiations.
1227 (push_template_decl_real): Build template decls with current template
1228 reqs. Don't pass constraints to build_template_info.
1229 (add_inherited_template_parms): Build new constraints from inherited
1230 template constructors.
1231 (redeclare_class_template): Update to new constraint interface.
1232 (is_compatible_template_arg): Update to new constraint interface.
1233 (lookup_template_class_1): Don't build new constraints or pass them to
1234 build_template_info.
1235 (instantiate_class_template_1): Update to new constraints interface.
1236 (tsubst_decl): Don't build new constraints or pass them to
1237 build_template_info. For function templates, explicitly instantiate
1238 new constraints for member functions of class templates.
1239 * gcc/cp/semantics.c: Associate constraints with template template
1240 parms directly, not through template info.
1241 * gcc/cp/constraint.cc (get_constraints): Simplified to use new constraints
1243 (check_constraints): Update to use new constraints interface.
1244 (equivalently_constrained): Update to use new constraints interface.
1245 (more_constrained): Update to use new constraints interface.
1246 * gcc/cp/parser.cpp (cp_parser_late_parsing_for_member): Update to use
1247 new constraints interface.
1248 * gcc/cp/call.c (is_non_template_member_fn): New.
1249 (add_function_candidate): Only check constraints for non-template member
1252 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1254 * gcc/cp/parser.c (cp_parser_requires_clause): Pulled out of
1255 cp_parser_requires_clause_opt for reuse in the requires expr parser.
1256 (cp_parser_requires_expression): New, along with a family of
1257 sub-expression parsers for the new feature.
1258 * gcc/cp/semantics.c (finish_requires_expr): Stub.
1259 (finish_syntax_requirement): Stub.
1260 (finish_type_requirement): Stub.
1261 (finish_constexpr_requirement): Stub.
1262 (finish_noexcept_requirement): Stub.
1263 (finish_requires_expr): Stub.
1264 * gcc/cp/cp-tree.h: (finish_requires_expr): New.
1265 (finish_syntax_requirement): New.
1266 (finsih_type_requirement): New.
1267 (finish_constexpr_requirement): New.
1268 (finish_noexcept_requirement): New.
1270 2013-06-21 Andrew Sutton <andrew.n.sutton@gmail.com>
1272 * gcc/cp/error.c (subst_to_string): Allow this to be called explicitly
1273 passing template parameters in the TREE_TYPE and with a null
1275 * constraint.cc (check_requirements): New overload taking template
1277 (check_constraints.cc): Move instantiation and checking into the
1278 new check_requirements overload.
1279 (diagnose_requirements): New family of functions for diagnosing
1280 constraint failures.
1282 2013-06-18 Andrew Sutton <andrew.n.sutton@gmail.com>
1284 * gcc/cp/class.c (are_constrained_member_overloads): New.
1285 (add_method): Allow overloading of constrained member functions.
1286 * gcc/cp/call.c (rejection_reason_code): New rr_constraint_failure.
1287 (template_constraint_failure): New.
1288 (add_function_candidate): Check for viability as a precondition to use.
1289 (add_template_candidate_real): Integrate constraint diagnostics.
1290 Provide constraint info for new template instantiations.
1291 (print_z_candidate): Emit diagnostics for constraint failures.
1292 (template_decl_for_candidate): New.
1293 (joust): Allow non-member templates of class templates to be evaluated
1294 in more_specialized_fn if they are constrained.
1295 * gcc/cp/ptree.c (cxx_print_xnode): Dump constraint info.
1296 * gcc/cp/semantics.c (finish_template_template_parm): Build template
1297 info for template template parameters.
1298 (is_unary_trait): New.
1299 (is_binary_trait): New.
1300 (finish_trait_expr): Check for binary traits using new function.
1301 * gcc/cp/constraint.cc (join_requirements): New
1302 (conjoin_requirements): Join expressions correctly. Fixed docs.
1303 (disjoin_requirements): Removed.
1304 (is_constriant): Removed.
1305 (resolve_constraint_check): New. Replaces previous get_constraint
1306 check and related functions.
1307 (get_constraints): New, along with helper functions.
1308 (suppress_template_processing): New.
1309 (check_template_constraints): New, along with helper functions.
1310 (equivalent_constraints): New.
1311 (equivalently_constrained): New.
1312 (more_constraints): New.
1313 (more_constrianed): New.
1314 (diagnose_constraint_failure): New.
1315 * gcc/cp/decl.c (decls_match): Check for constraint equivalence if
1316 the types are the same.
1317 (check_concept_refinement): New.
1318 (are_constrained_overloads): New.
1319 (duplicate_decls): Handle constraints for ambigous declarations. Check
1320 and diagnose concept refinement.
1321 (check_concept_fn): Don't fail completely just because the concept
1322 isn't defined correctly. Allow analysis to continue as if declared
1323 constexpr. Concepts must return bool.
1324 * gcc/cp/tree.c (bind_template_template_parm): Provide empty
1325 constraints for bound template template parameters.
1326 * gcc/cp/logic.cc: Rewrite of proof state and related structures and
1327 decomposition logic. Removed right-decomposition logic, but retained
1328 right-logical rules.
1329 (match_terms): Renamed from entails.
1330 (subsumes_prop): Cleanup, added specific handlers for and/or cases.
1331 (subsumes_constraints): Update from interface change.
1332 * gcc/cp/cp-tree.h (check_constraint_info): Renamed and applied
1334 (check_template_info): Renamed and applied interface change.
1335 (cp_unevaluated): New
1336 (local_specialization_stack): New.
1337 (coerce_template_parms): New.
1338 (is_unary_trait): New.
1339 (is_binary_trait): New.
1340 (get_constraints): New.
1341 (check_constraints): New.
1342 (check_template_constraints): New.
1343 (subst_template_constraints): New.
1344 (equivalent_constraints): New.
1345 (equivalently_constrained): New.
1346 (more_constraints): New.
1347 (more_constrained): New.
1348 (diagnose_constraints_failure): New.
1349 * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Print the
1350 template requirements.
1351 * gcc/cp/pt.c (local_specialization_stack): New.
1352 (build_template_info): Refactor into 3-argument version and
1353 incorporate template requirements.
1354 (check_explicit_specialization): Instantiate requirements for
1356 (push_template_decl_real): Include constraints in template info.
1357 (redeclare_class_template): Diagnose redeclaration with different
1359 (is_compatible_template_arg): New.
1360 (convert_template_argument): Check constraints on template template
1361 arguments and diagnose errors.
1362 (lookup_template_class_1): Check constraints on alias templates.
1363 Keep constraints with instantiated types.
1364 (instantiate_class_template_1): Check constraints on class templates.
1365 (tsubst_decl): Instantiate and keep constraints with template info.
1366 Also, allow dependent pack arguments to produce neww parameter
1367 packs when instantiated.
1368 (coerce_template_parms): New overload.
1369 (tsubst_copy): Handle REAL_TYPE and BOOLEAN_TYPE.
1370 (tsubst_copy_and_build): PARM_DECLs can be instantiated as pack
1371 expansions (used with requires expression).
1372 (fn_type_unification): Check constraints for function templates.
1373 (more_specialized_fn): Determine which candidate is more constrained.
1374 (substitute_template_parameters): Removed.
1375 (tsubst_constraint): New.
1376 (substitute_requirements): New.
1377 * gcc/cp/parser.c: (cp_parser_optional) Removed along with helper
1379 (cp_unevaluated): New.
1380 (cp_parser_type_parameter): Check for requires kw explicitly, and
1381 save/clear template requirements before parsing the requires clause.
1382 (cp_parser_requires_clause): Removed.
1383 (cp_parser_template_declaration_after_exp): Check for requires kw
1385 * gcc/system.h (cstdlib): Removed include.
1386 * gcc/c-family/c-common.h (D_CXX_CONCEPTS): New flag for disabling
1388 * gcc/c-family/c.opt (flag_concepts): Remove redundant declaration.
1389 * gcc/c-family/c-common.c (c_common_r): Concept-specific keywords
1390 are only enabled when concepts are enabled.
1392 2013-06-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1394 * gcc/system.h (cstdlib): Include <cstdlib> to avoid poisoned
1396 * gcc/c-family/common.c (c_common_r): Added __is_same_as intrinsic,
1397 removed previous, unused intrinsics.
1398 * gcc/c-family/common.h (rid): Added RID_IS_SAME_AS.
1399 * gcc/cp/parser.c (take): New.
1400 (cp_requires_clause): New.
1401 (cp_requires_clause_opt): New.
1403 (cp_parser_optional_if_token): New.
1404 (cp_parser_optional_if_not_token): New.
1405 (cp_parser_optional_if_keyword): New.
1406 (cp_parser_decl_specifier_seq): Parse 'concept' as a declspec.
1407 (cp_parser_type_parameter): Parse constrained template template parms.
1408 (cp_parser_member_specification_opt): Parse member constraints after
1409 the declaration, not before.
1410 (cp_parser_template_declaration_after_exp): Rewrote parsing for
1411 template requirements
1412 (cp_parser_late_parsing_for_member): Re-push the current template
1413 requirements when late-parsing member definitions.
1414 * gcc/cp/decl.c (check_concept_fn): New.
1415 (grokfndecl): Semantics for concept declspec.
1416 (grokdeclarator): Semantics for concept declspec.
1417 (xref_tag_1): Update to new interface.
1418 * gcc/cp/constraint.cc (make_constraints): New.
1419 * gcc/cp/cp-objcp-common.c (cp_tree_size): Add case for constraint_info.
1420 * gcc/cp/cp-tree.h (require): New.
1421 (tree_template_info): Add a field for constraint info.
1422 (tree_constraint_info): New.
1423 (constraint_info_p): New.
1424 (template_info_p): New.
1426 (CI_REQUIREMENTS): New.
1427 (CI_ASSUMPTIONS): New.
1428 (TI_CONSTRAINT): New.
1430 (TI_REQUIREMENTS): New.
1431 (TI_ASSUMPTIONS): New.
1432 (DECL_TEMPLATE_CONSTRAINT): New.
1433 (CLASSTYPE_TEMPLATE_CONSTRAINT): New.
1434 (ENUM_TEMPLATE_CONSTRAINT): New.
1435 (TEMPLATE_TEMPLATE_PARM_TEMPLATE_CONSTRAINT): New.
1436 (TYPE_TEMPLATE_CONSTRAINT): New.
1437 (cp_tree_node_structure_enum): Added entry for constraint info.
1438 (lang_tree_node): Added entry for constraint info.
1439 (lang_decl_base): Added bit for concept declarations.
1440 (DECL_DECLARED_CONCEPT_P): New.
1441 (cp_decl_spec): Added ds_concept declaration specifier.
1442 * gcc/cp/Make-lang.in (logic.o): New target.
1443 * gcc/cp/semantics.c (finish_template_requirements): Rewrite.
1444 * gcc/cp/logic.cc: New
1445 * gcc/cp-tree.def (CONSTRAINT_INFO): New node.
1446 * gcc/cp/pt.c (current_template_args): Make non-static.
1447 (redeclare_class_template): Take constraints as a 3rd argument
1449 2013-04-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1451 * gcc/cp/Make-lang.in: Add constraints.o target.
1452 * gcc/cp/cp-tree.h (substitute_template_parameters): Declare.
1453 (instantiate_requirements): Declare.
1454 (conjoin_requirements): Declare.
1455 (disjoin_requirements): Declare.
1456 (reduce_requirements): Declare.
1457 * gcc/cp/pt.c (substitute_template_parameters): Define.
1458 (instantiate_requirements): Define.
1459 * gcc/cp/pt.c (finish_template_requirements): Call
1460 reduce_requirements to get constraints.
1461 * gcc/cp/parser.c (cp_parser_type_parameter): Restore saved
1462 constraints after parsing template template parameter decl.
1463 * gcc/cp/constraints.cc: New.
1465 2013-03-11 Andrew Sutton <andrew.n.sutton@gmail.com>
1467 * gcc/cp/Make-lang.in: Add constraint.c
1468 * gcc/cp/constraint.c: New
1469 (conjoin_requirements): New
1470 (disjoin_requirements): New
1471 (requirement_reduction): New class
1472 (reduce_requirements): New
1473 * gcc/cp/cp-tree.h (reduce_requrements): New
1474 (conjoin_requirements): New
1475 (disjoin_requirements): New
1476 * gcc/cp/cp-tree.h (finish_template_template_parm) Comments.
1477 * gcc/cp/semantics.c (finish_template_requirements) Start
1478 working with requirements.
1481 2013-03-01 Andrew Sutton <andrew.n.sutton@gmail.com>
1483 * gcc/cp/cp-tree.h (saved_scope): Add template requirements.
1484 (finish_template_requirements): Declare
1485 * gcc/cp/parser.c (cp_parser_template_requirement_opt): Declare.
1486 (cp_parser_template_declaration): Document grammar extensions.
1487 (cp_parser_type_parameter): Parse requirements for template
1488 template parameters.
1489 (cp_parser_member_declaration): Parse requirements for
1490 members of class templates.
1491 (cp_parser_template_requirement_opt): Define.
1492 (cp_parser_template_declaration_after_exp): Parse requirements
1493 for template declarations.
1494 * gcc/cp/semantics.c (finish_template_requirements): Define.
1495 * gcc/cp/lex.c (cxx_init): Enable concepts by default.
1497 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
1499 * lex.c (flag_concepts): Revert left over declaration.
1501 2013-03-01 Gabriel Dos Reis <gdr@integrable-solutions.net>
1503 * gcc/c-family/c-common.c (cxx_dialect): Set C++11 as default.
1504 * gcc/c-family/c.opt(flag_concepts): Add.
1505 * gcc/cp/lex.c (flag_concepts): New. Enabled concept support by
1508 2013-02-28 Andrew Sutton <andrew.n.sutton@gmail.com>
1510 * gcc/c-family/c-common.h (rid): New resreserved words for concepts.
1511 * gcc/c-family/c-common.c (c_common_reswords): Definitions thereof.
1512 * gcc/doc/extend.texi (write_symbol): Initial concept docs.