2014-06-28 Andrew Sutton <andrew.n.sutton@gmail.com>
[official-gcc.git] / ChangeLog.concepts
blob4393f3461140c89f528a3a87e1c02aa36295cefc
1 2014-06-28  Andrew Sutton  <andrew.n.sutton@gmail.com>
2         * gcc/c-family/c.opt (flag_concepts): Don't enable by default.
3         * gcc/c-family/c-opts.c (set_std_cxx1z): Enable concepts if
4         -std=cxx1z is selected.
5         * gcc/c-family/c-format.c (gcc_cxxdia): Add "Z" as format specifier.
6         * gcc/cp/c-common.c (cxx_dialect): Make -std=c++98 the default
7         language again.
8         * gcc/cp/lex.c (cxx_init): Don't set flag_concepts explicitly.
9         * gcc/testsuite/g++.dg/concepts/*.C: Updat build flags.
12 2014-06-28  Andrew Sutton  <andrew.n.sutton@gmail.com>
13         * gcc/cp/cp-tree.h (DECL_CONSTRAINTS): Remove this macro; use
14         get_constraints instead.
15         (set_constraints): new.
16         * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Use
17         get_constraints.
18         * gcc/cp/pt.c (get_specialization_constraints): Use get_constraints.
19         (build_template_decl): Use get_constraints.
20         (process_partial_specialization): Use get_constraints.
21         (add_inherited_template_parms): Use get_constraints.
22         (redeclare_class_template): Use get_constraints.
23         (is_compatible_template_arg): Use get_constraints.
24         (tsubst_friend_class): Use get_constraints.
25         (tsubst_decl): Uset get_constraints.
26         * gcc/cp/semantics.c (finish_template_template_parm): Use
27         get_constraints.
28         (fixup_template_type): Use get_constraints.
29         * gcc/cp/constraint.cc (constraints): New global association
30         of declarations to constraints.
31         (get_constraints): Return the associated constraints from the
32         hash table.
33         (set_constraints): New. Associate constraints with a declaration.
34         (check_template_constraints): Use get_constraints.
35         (equivalently_constrained): Use get_constraints.
36         (more_constrained): Use get_constraints.
37         (diagnose_constraints): Use get_constraints.
38         * gcc/testsuite/g++.dg/concepts/partial-spec.C: New.
40 2014-06-25  Andrew Sutton  <andrew.n.sutton@gmail.com>
41         * gcc/cp/parser.c (cp_parser_requires_clause): Don't fold expressions
42         when parsing a requires-clause.
43         * gcc/cp/constraint.cc (reduce_requirements): Don't fold
44         expressions during constraint normalization.
46 2014-06-24  Andrew Sutton  <andrew.n.sutton@gmail.com>
47         * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): Defer
48         handling the BASELINK check until concept-resolution in order to
49         allow member conceps.
50         (cp_parser_nonclass_name): Also Check for concept-names when the
51         lookup finds a BASELINk.
52         * gcc/cp/constraint.cc: (resolve_constraint_check) If the call
53         target is a base-link, resolve against its overload set.
54         (build_concept_check): Update comments and variable names to
55         reflect actual processing.
56         * gcc/testuite/g++.dg/concepts/mem-concept.C: New test.
57         * gcc/testuite/g++.dg/concepts/mem-concept-err.C: New test.
59 2014-06-24  Andrew Sutton  <andrew.n.sutton@gmail.com>
60         * gcc/cp/error.c (dump_expr): Pretty print placeholder to improve
61         debug output.
63 2014-06-17  Braden Obrzut  <admin@maniacsvault.net>
64         * gcc/cp/parser.c (cp_maybe_constrained_type_specifier): If getting
65         a baselink, use the referred-to function/overload declarations rather
66         than asserting.
68 2014-06-12  Andrew Sutton  <andrew.n.sutton@gmail.com>
69         * gcc/cp/constraint.cc (deduce_constrained_parameter): Refactor
70         common deduction framework into separate function.
71         (build_call_check): New.
72         (build_concept_check): Take additional arguments to support the
73         creation of constrained-type-specifiers from partial-concept-ids.
74         (build_constrained_parameter): Take arguments from a partial-concept-id.
75         * gcc/cp/cp-tree.h (build_concept_check, biuld_constrained_parameter):
76         Take a template argument list, defaulting to NULL_TREE.
77         * gcc/cp/parser.c (cp_parser_template_id): Check to see if a 
78         template-id is a concept check.
79         (cp_check_type_concept): Reorder arguments
80         (cp_parser_allows_constrained_type_specifier): New. Check contexts
81         where a constrained-type-specifier is allowed.
82         (cp_maybe_constrained_type_specifier): New. Refactored common rules
83         for concept name checks.
84         (cp_maybe_partial_concept_id): New. Check for 
85         constrained-type-specifiers.
86         * gcc/testuite/g++.dg/concepts/partial.C: New tests.
87         * gcc/testuite/g++.dg/concepts/partial-err.C: New tests.
88         * gcc/testuite/g++.dg/concepts/concepts.exp: Add missing test driver.
90 2014-06-12  Andrew Sutton  <andrew.n.sutton@gmail.com>
91         * gcc/cp/parser.c (cp_check_type_concept): New.
92         (cp_check_concept_name): Remove redundant condition from check.
93         Diagnose misuse of non-type concepts in constrained type specifiers.
94         * gcc/testuite/g++.dg/concepts/generic-fn.C: Add tests for
95         non-simple constrained-type-specifiers and nested-name-specifiers
96         in concept names.
97         * gcc/testuite/g++.dg/concepts/generic-fn-err.C: New tests for
98         diagnosing ill-formed programs.
100 2014-06-11  Andrew Sutton  <andrew.n.sutton@gmail.com>
101         * gcc/cp/cp-tree.h (build_constrained_parameter): Renamed fro
102         describe_tempalte_parm.
103         * gcc/cp/parser.c (cp_check_constrained_type_parm): New. Prevent
104         declaration of cv-qualifed or non-id types.
105         (cp_constrained_type_template_parm): Renamed, check for invalid 
106         specifiers.
107         (cp_constrained_template_template_parm): Renamed, check for invalid
108         specifiers.
109         (cp_constrained_non_type_tmeplate_parm): Renamed.
110         (cp_finish_constrained-parameter): Support checking of decarlarations.
111         (cp_check_concept_name): Renamed. Add initial support for auto
112         and constrained-type-specifiers in compound requirements.
113         (cp_parser_nonclass_name): Only check for concept names if -fconcepts
114         is on.
115         (cp_manage_requirements): New RAII guard for managinging the
116         current_template_reqs variable during declaration parsing.
117         (cp_paresr_trailing_requirements): Refactored common parsing
118         requirements from cp_parser_init_declarator and 
119         cp_parser_member_declarator. Take terse constraints from implicit
120         parameter declarations.
121         (cp_parser_init_declarator): Cleanup, refactor requirement logic.
122         (cp_parser_type_id_1): Allow auto in compound requirements.
123         (cp_parser_member_declaration): Cleanup, refactor requirement logic.
124         (cp_parser_compound_requirement): Note parsing state for the 
125         trailing-type-id so we can get auto and constrained-type-specifiers.
126         (cp_parser_function_definition_after_decl): Remove broken constraint
127         association.
128         * gcc/cp/parser.h (cp_parser): New member.
129         * gcc/cp/constraint.cc (finish_validtype_expr): Initial (non-)handling
130         of auto in type requirements.
131         (finish_concept_name): Moved to cp_check_concept_name.
132         * gcc/testuite/g++.dg/concepts/constrained-parm.C: New test.
133         * gcc/testuite/g++.dg/concepts/generic-fn.C: New test.
136 2014-03-10  Andrew Sutton  <andrew.n.sutton@gmail.com>
137         * gcc/testuite/g++.dg/concepts/fn1.C: New test.
138         * gcc/testuite/g++.dg/concepts/fn2.C: New test.
140 2013-11-012  Andrew Sutton  <andrew.n.sutton@gmail.com>
141         * gcc/cp/parser.c (synthesize_implicit_template_parm): Allow concepts
142         to declare implicit template parameters. Only synthesize new parameters
143         if the concept name is new.
144         (finish_concept_name): Moving into parser.c for the time being. Needs
145         to be rewritten to remove duplicate code between parser.c and
146         constraint.cc.
148 2013-11-012  Andrew Sutton  <andrew.n.sutton@gmail.com>
149         * gcc/cp/pt.c (tsubst_copy): Expand pack expansions as conjunctions.
151 2013-11-012  Andrew Sutton  <andrew.n.sutton@gmail.com>
152         * gcc/cp/pt.c (tsubst_pack_conjunction): Don't try to conjoin
153         dependent expressions.
155 2013-11-012  Andrew Sutton  <andrew.n.sutton@gmail.com>
156         * gcc/cp/semantics.c (fixup_template_type): Compare primary template
157         types to specializations using structural types so we don't run into
158         canonical type errors with constrained specializations.
160 2013-11-08  Andrew Sutton  <andrew.n.sutton@gmail.com>
161         * gcc/cp/pt.c (add_inherited_template_parms): Instantiate requirements
162         in a processing template decl context.
164 2013-11-05  Andrew Sutton  <andrew.n.sutton@gmail.com>
165         * gcc/cp/semantics.c (fixup_template_type): Add a same-type check
166         for specialiations so we don't accidentally match non-dependent
167         specializations having a different type.
169 2013-10-26  Ville Voutilainen  <ville.voutilainen@gmail.com>
170         * gcc/cp/decl.c (grokdeclarator): Reject concept keyword
171         in typedefs, function parameters, data members, non-static
172         member functions and variables. Allow static member functions
173         to be concepts.
175 2013-10-30  Andrew Sutton  <andrew.n.sutton@gmail.com>
176         * gcc/cp/semantics.c (fixup_template_type): Don't emit errors when
177         no templates can be found with matching constraints.
179 2013-10-25  Andrew Sutton  <andrew.n.sutton@gmail.com>
180         * gcc/cp/parsre.c (cp_parser_requires_expression): Gracefully
181         fail when parsing a requires expr outside a template.
183 2013-10-24  Andrew Sutton  <andrew.n.sutton@gmail.com>
184         * gcc/cp/c-common.c (c_common_r): Remove unused keywords "assume",
185         "axiom", and "forall".
186         * gcc/cp/c-common.h (rid): Removed unused reserved word ids.
188 2013-10-24  Edward Smith-Rowland  <3dw4rd@verizon.net>
189         * gcc/cp/typeck.c (cp_build_function_call_vec): Use unused variable 
190         loc.
192 2013-10-23  Andrew Sutton  <andrew.n.sutton@gmail.com>
193         * gcc/cp/class.c (get_member_fntemplate): New.
194         (are_constrained_member_overloads): Only get a template declaration
195         if the member function is, in fact, a template or temploid.
196         * gcc/cp/pt.c (check_explicit_specialization): Do not allow
197         explicit specializations to be declared 'concept', and do not allow
198         an explicit specialization of a concept.
199         * gcc/cp/decl.c (grokfndecl): Propagate the concept flag to
200         check_explicit_specialization.
202 2013-10-22  Andrew Sutton  <andrew.n.sutton@gmail.com>
203         * gcc/c-family/c-common.c (cxx_dialect): Make the default
204         language C++11.
205         * gcc/cp/constraint.cc (check_constrained_friend): Don't assert
206         on error_mark_node.
208 2013-10-16  Andrew Sutton  <andrew.n.sutton@gmail.com>
209         * gcc/cp/logic.cc (left_requires), (decompose_left): Add
210         decomposition rules for requires expressions.
211         (subsumes_requires), (subsumes_prop): Add subsumption rules for
212         requires expressions.
213         * gcc/cp/constraint.cc (diagnose_trait): Diagnose failed conversion
214         requirements.
216 2013-10-16  Andrew Sutton  <andrew.n.sutton@gmail.com>
217         * gcc/cp/constraint.cc (finish_concept_name): Allow functions with
218         the same name as concepts to resolve as call expressions in the
219         usual way.
221 2013-10-16  Andrew Sutton  <andrew.n.sutton@gmail.com>
222         * gcc/cp/constraint.cc (conjoin_requiremens): New.
223         (resolve_constraint_check): Filter non-concept candidates before
224         coercing arguments. Perform deduction in a template-decl processing
225         context to prevent errors during diagnosis.
226         (finish_concept_name), (finish_shorthand_requirement),
227         (get_shorthand_requirements): New.
228         * gcc/cp/pt.c (template_parm_to_arg): Make non-static.
229         (process_templat_parm): Build shorthand requirements from the
230         parameter description.
231         (end_templat_parm_list): New.
232         (convert_placeholder_argument): New.
233         (convert_template_argument): Match placeholder arguments against
234         any template parameter.
235         (tsubst_pack_conjuction):  New.
236         (tsubst_expr): Expand a pack as a conjunction.
237         (type_dependent_expression_p): Placeholders are always type
238         dependent.
239         * gcc/cp/parser.c (cp_is_constrained_parameter), 
240         (cp_finish_template_type_parm), (cp_finish_template_template_parm)
241         (cp_finish_non_type_template_parm), (cp_finish_constrined_parameter):
242         New.
243         (cp_parser_template_parameter): Handle constrained parameters.
244         (cp_parser_nonclass_name): An identifier naming an overload set
245         may declare a constrained parameter.
246         (cp_parser_type_parameter), (cp_parser_template_declaration_after_exp): 
247         Get shorthand requirements from the tmeplate parameter list.
248         * gcc/cp/cp-tree.h (TEMPLATE_PARM_CONSTRAINTS): New.
250 2013-10-07  Andrew Sutton  <andrew.n.sutton@gmail.com>
251         * gcc/cp/cp-tree.h (check_constrained_friend): Take requirements as
252         an argument.
253         * gcc/cp/constraints.cc (check_constrained_friend): Do not diagnose
254         errors in unconstrained friend declarations.
255         * gcc/cp/parser.cc (cp_parser_member_declaration): Pass current
256         requirements to check_constrained_friend.
258 2013-10-07  Andrew Sutton  <andrew.n.sutton@gmail.com>
259         * gcc/cp/parser.c (cp_parser_member_declaration): Check that
260         a constrained friend definition is valid.
261         * gcc/cp/decl.c (grokfndecl): Disallow constrained friend template
262         specializations.
263         * gcc/cp/constraints.cc (check_constrained_friend): New.
264         * gcc/cp/typeck.c (cp_build_function_call_vec): Diagnose constraints
265         in the presence of the failure of a single candidate.
266         * gcc/cp/cp-tree.h (check_constrained_friend): New.
267         * gcc/cp/call.c (is_non_template_member_fn): Make inline.
268         (is_non_template_friend), (is_constrainable_non_template_fn): New.
269         (add_function_candidate): Predicate check on
270         is_constrainable_non_template_fn.
272 2013-09-10  Andrew Sutton  <andrew.n.sutton@gmail.com>
273         * gcc/cp/cp-tree.h (TEMPLATE_PARMS_CONSTRAINTS): New.
274         * gcc/cp/parser.c (cp_parser_template_declaration_after_export),
275         (cp_parser_type_parameter): Use TEMPLATE_PARMS_CONSTRAINTS.
276         * gcc/cp/semantics.c (fixup_template_scope): Use 
277         TEMPLATE_PARMS_CONSTRAINTS.
279 2013-09-11  Andrew Sutton  <andrew.n.sutton@gmail.com>
280         * gcc/cp/cxx-pretty-print.c (pp_cxx_compound_requirement),
281         (pp_cxx_type_requirement), (pp_cxx_validtype_expr): Use 
282         pp->type_id() instead of pp_cxx_type_id().
284 2013-09-09  Andrew Sutton  <andrew.n.sutton@gmail.com>
285         * gcc/cp/pt.c (get_class_bindings): Pass the partial specialization
286         for constraint evaluation. Evaluate constraints, resulting in
287         deduction failure on error.
288         (get_specializaing_template_decl), (get_specialization_constraints),
289         (maybe_new_partial_specialization): New.
290         (maybe_process_partial_specialization): Allow the creation of
291         new types for constrained partial specializations.
292         (process_partial_specialization): Modify the canonical type
293         of constrained partial specializations.
294         (instantiate_class_template_1): Do not explicitly check constraints
295         during class template instantiation.
296         (tsubst_decl): Instantiate the constraints of template declarations.
297         (more_specialized_class): Pass specializations to get_class_bindings().
298         Compare specialization constraints if the types are equivalent.
299         (most_specialized_class): Pass specialization to get_class_bndings().
300         * gcc/cp/decl2.c (check_class_fn): Get the decl's requirements from
301         either the current template reqs or from the template parameters.
302         Allow overloading of constrained out-of-class member definitions.
303         * gcc/cp/semantics.c (fixup_template_type): New. Match the template
304         scope to a specialization with appropriate constraints.
305         (finish_template_type): Fix template type when entering scope.
306         * gcc/cp/parser.c (cp_parser_parse_type_parameter): Attach
307         requirements to the current template parameter list.
308         (cp_parser_init_declarator): Parse requires clauses for out-of-class
309         member definitions. Be sure to restore current constraints before
310         exiting the function.
311         (cp_parser_member_declarator): Restore the previous requirements in
312         an early-exit branch.
313         (cp_parser_late_parsing_for_member): Restore constraints after
314         maybe_end_member_template_processing().
315         (cp_parser_template_declaration_after_exp): Attach constraints to
316         the current template parameters.
317         * gcc/cp/constraint.cc (reduce_template_id): Don't crash when
318         omitting ()'s on constraint calls.
319         (check_requirements): Don't evaluate dependent arguments.
320         (check_constraints): Don't try to evaluate when arguments are
321         dependent.
322         (equivalent_constraints): Optimize the case when a and b are the
323         same constraints.
325 2013-07-26  Andrew Sutton  <andrew.n.sutton@gmail.com>
326         * gcc/cp/semantics.c (trait_expr_value): Evaluate __is_same_as.
327         (finish_trait_expr): Check __is_same_as and __is_convertible_to.
328         * gcc/cp/constraint.cc (diagnose_trait): Diagnose failures in
329         __is_same_as.
330         * gcc/cp/parser.c (cp_parser_primary_expression), 
331         (cp_parser_trait_expr): Parse __is_same_as.
332         * gcc/cp/cp-tree.h (cp_trait_kind): Add CPTK_IS_SAME_AS.
333         * gcc/cp/cxx-pretty-print.c (pp_cxx_trait_expression): Pretty print
334         __is_same_as trait.
336 2013-07-26  Andrew Sutton  <andrew.n.sutton@gmail.com>
337         * gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
338         requires expr parameter list.
340 2013-07-25  Andrew Sutton  <andrew.n.sutton@gmail.com>
341         * gcc/cp/parser.c (cp_parser_requires_expr): Update parser using new
342         requires expression nodes. Renamed some grammar productions to better 
343         reflect the representation of the syntax. Create a new scope for 
344         requires parameters.
345         (cp_parser_nested_requirement): Wrap results in a NESTED_REQ node.        
346         * gcc/cp/semantics.c (xvalue_result_type): New.
347         (trait_expr_value): Evaluate __is_convertible_to.
348         (finish_requires_expr): Implemented, along with other functions to
349         construct and evaluate nodes for template constraints.
350         (potential_constant_expression_1): Handle requires expressions.
351         (finish_template_requirements), (finish_requires_expr), etc:
352         Move to constraint.cc.
353         * gcc/cp/cp-tree.def: (REQUIRES_EXPR), (EXPR_REQ), (TYPE_REQ),
354         (NESTED_REQ), (VALIDEXPR_EXPR), (VALIDTYPE_EXPR), (CONSTEXPR_EXPR):
355         New.
356         * gcc/cp/cp-objcp-common.c (cp_common_init_ts): Make new nodes typed.
357         * gcc/cp/cp-tree.h (finish_expr_requirement), 
358         (finish_type_requirement), (finish_nested_requirement),
359         (finish_validexpr_expr), (finish_validtype_expr),
360         (finish_constexpr_expr): New.
361         * gcc/cp/pt.c (convert_nontype_argument): Use can_convert_standard.
362         (retrieve_local_specialization), (register_local_specialization),
363         (extract_fnparm_pack): Make non-static.
364         (tsubst_expr): Substitution rules for requires expressions.
365         (instantiate_requirements): Move to constraints.cc
366         (tsubst_constraint): Remove.
367         * gcc/cp/call.c (can_convert): Allow user-defined conversions.
368         (can_convert_standard): New.
369         * gcc/cp/cvt.c (convert_to_reference): Use can_convert_standard.
370         * gcc/cp/search.c (check_final_overrider): Use can_cnvert_standard.
371         * gcc/cp/typeck.c (build_static_cast_1): Use can_convert_standard.
372         * gcc/cp/error.c (dump_expr): Pretty print new nodes.
373         * gcc/cp/cxx-pretty-print.c (pp_cxx_primary_expression): Pretty
374         print new expr/req nodes.
375         (pp_cxx_requires_expr): New along with related functions for
376         pretty printing requirements.
377         (pp_cxx_parameter_declaration_clause): Accommodate "raw" parameter
378         lists in addition to function decls.
379         (pp_cxx_requirement_parameter_list): Unified with parameter decl clause.
380         * gcc/cp/cxx-pretty-print.h (pp_cxx_requires_expr): New along with
381         related functions for pretty printing requirements.     
382         * gcc/cp/logic.cc: Move header comments to top of file.
383         * gcc/cp/constraint.cc (reduce_requirements): Handle requires
384         expressions.
385         (diagnose_constraints): Rename and handle requires expressions.
387 2013-07-01  Andrew Sutton  <andrew.n.sutton@gmail.com>
388         * gcc/cp/error.c (cp_printer): Fix unnecessary whitespace change.
389         * gcc/cp/constraint.cc (diagnose_node): Don't fail diagnosing
390         disjunctions.
392 2013-07-01  Andrew Sutton  <andrew.n.sutton@gmail.com>
393         * gcc/cp/class.c (are_constrained_member_overloads): Fix doc typos.
395 2013-06-24  Andrew Sutton  <andrew.n.sutton@gmail.com>
396         * gcc/cp/parser.c (cp_parser_init_declarator): Parse template
397         requirements for out-of-class member definitions.
398         * gcc/cp/decl2.c (check_classfn): Include match out-of-class
399         definitions using constraints.
400         * gcc/cp/constraint.cc (equivalently_constrained). Use get_constraints.
401         (more_constrained). Use get_constraints. 
403 2013-06-24  Andrew Sutton  <andrew.n.sutton@gmail.com>
404         * gcc/cp/cp-tree.h (tree_template_info). Remove constraint from 
405         template info.
406         (check_template_info): Removed (unused).
407         (TI_CONSTRAINT): Removed (no longer needed) along with related macros.
408         (DECL_CONSTRAINTS): New. Get constraints from DECL_SIZE_UNIT for 
409         template decls.
410         (build_template_info): Removed overload taking constraints.
411         (get_constraints): Removed (no longer needed).
412         * gcc/cp/class.c (are_constrained_member_overlaods): Allow constrained 
413         member function templates to be differentiated as overloads.
414         * gcc/cp/decl.c (decls_match): Only compare constraints on 
415         declarations.
416         (grokfndecl): Don't pass constraints to build_template_info.
417         * gcc/cp/tree.c (bind_template_template_parm): Don't pass constraints 
418         to build_template_info.
419         * gcc/cp/pt.c (build_template_info): Removed overload taking 
420         constraints.
421         (check_explicit_specialization): Don't build new constraints for 
422         template info.
423         (build_template_decl): Pass constraints. Update docs.
424         (process_partial_specialization): Stub out support for constrained
425         partial specialiations.
426         (push_template_decl_real): Build template decls with current template 
427         reqs. Don't pass constraints to build_template_info.
428         (add_inherited_template_parms): Build new constraints from inherited
429         template constructors.
430         (redeclare_class_template): Update to new constraint interface.
431         (is_compatible_template_arg): Update to new constraint interface.
432         (lookup_template_class_1): Don't build new constraints or pass them to
433         build_template_info.
434         (instantiate_class_template_1): Update to new constraints interface.
435         (tsubst_decl): Don't build new constraints or pass them to
436         build_template_info. For function templates, explicitly instantiate
437         new constraints for member functions of class templates.
438         * gcc/cp/semantics.c: Associate constraints with template template 
439         parms directly, not through template info.
440         * gcc/cp/constraint.cc (get_constraints): Simplified to use new constraints
441         interface.
442         (check_constraints): Update to use new constraints interface.
443         (equivalently_constrained): Update to use new constraints interface.
444         (more_constrained): Update to use new constraints interface.
445         * gcc/cp/parser.cpp (cp_parser_late_parsing_for_member): Update to use 
446         new constraints interface.
447         * gcc/cp/call.c (is_non_template_member_fn): New.
448         (add_function_candidate): Only check constraints for non-template member
449         functions.
451 2013-06-21  Andrew Sutton  <andrew.n.sutton@gmail.com>
452         * gcc/cp/parser.c (cp_parser_requires_clause): Pulled out of
453         cp_parser_requires_clause_opt for reuse in the requires expr parser.
454         (cp_parser_requires_expression): New, along with a family of
455         sub-expression parsers for the new feature.
456         * gcc/cp/semantics.c (finish_requires_expr): Stub.
457         (finish_syntax_requirement): Stub.
458         (finish_type_requirement): Stub.
459         (finish_constexpr_requirement): Stub.
460         (finish_noexcept_requirement): Stub.
461         (finish_requires_expr): Stub.
462         * gcc/cp/cp-tree.h: (finish_requires_expr): New.
463         (finish_syntax_requirement): New.
464         (finsih_type_requirement): New.
465         (finish_constexpr_requirement): New.
466         (finish_noexcept_requirement): New.
468 2013-06-21  Andrew Sutton  <andrew.n.sutton@gmail.com>
469         * gcc/cp/error.c (subst_to_string): Allow this to be called explicitly
470         passing template parameters in the TREE_TYPE and with a null 
471         TREE_PURPOSE.
472         * constraint.cc (check_requirements): New overload taking template
473         arguments.
474         (check_constraints.cc): Move instantiation and checking into the
475         new check_requirements overload.
476         (diagnose_requirements): New family of functions for diagnosing 
477         constraint failures.
479 2013-06-18  Andrew Sutton  <andrew.n.sutton@gmail.com>
480         * gcc/cp/class.c (are_constrained_member_overloads): New.
481         (add_method): Allow overloading of constrained member functions.
482         * gcc/cp/call.c (rejection_reason_code): New rr_constraint_failure.
483         (template_constraint_failure): New.
484         (add_function_candidate): Check for viability as a precondition to use.
485         (add_template_candidate_real): Integrate constraint diagnostics.
486         Provide constraint info for new template instantiations.
487         (print_z_candidate): Emit diagnostics for constraint failures.
488         (template_decl_for_candidate): New.
489         (joust): Allow non-member templates of class templates to be evaluated
490         in more_specialized_fn if they are constrained.
491         * gcc/cp/ptree.c (cxx_print_xnode): Dump constraint info.
492         * gcc/cp/semantics.c (finish_template_template_parm): Build template
493         info for template template parameters.
494         (is_unary_trait): New.
495         (is_binary_trait): New.
496         (finish_trait_expr): Check for binary traits using new function.
497         * gcc/cp/constraint.cc (join_requirements): New
498         (conjoin_requirements): Join expressions correctly. Fixed docs.
499         (disjoin_requirements): Removed.
500         (is_constriant): Removed.
501         (resolve_constraint_check): New. Replaces previous get_constraint
502         check and related functions.
503         (get_constraints): New, along with helper functions.
504         (suppress_template_processing): New. 
505         (check_template_constraints): New, along with helper functions.
506         (equivalent_constraints): New.
507         (equivalently_constrained): New.
508         (more_constraints): New.
509         (more_constrianed): New.
510         (diagnose_constraint_failure): New.
511         * gcc/cp/decl.c (decls_match): Check for constraint equivalence if
512         the types are the same.
513         (check_concept_refinement): New.
514         (are_constrained_overloads): New.
515         (duplicate_decls): Handle constraints for ambigous declarations. Check
516         and diagnose concept refinement.
517         (check_concept_fn): Don't fail completely just because the concept
518         isn't defined correctly. Allow analysis to continue as if declared
519         constexpr. Concepts must return bool.
520         * gcc/cp/tree.c (bind_template_template_parm): Provide empty 
521         constraints for bound template template parameters.
522         * gcc/cp/logic.cc: Rewrite of proof state and related structures and
523         decomposition logic. Removed right-decomposition logic, but retained
524         right-logical rules.
525         (match_terms): Renamed from entails.
526         (subsumes_prop): Cleanup, added specific handlers for and/or cases.
527         (subsumes_constraints): Update from interface change.
528         * gcc/cp/cp-tree.h (check_constraint_info): Renamed and applied
529         interface change.
530         (check_template_info): Renamed and applied interface change.
531         (cp_unevaluated): New
532         (local_specialization_stack): New.
533         (coerce_template_parms): New.
534         (is_unary_trait): New.
535         (is_binary_trait): New.
536         (get_constraints): New.
537         (check_constraints): New.
538         (check_template_constraints): New.
539         (subst_template_constraints): New.
540         (equivalent_constraints): New.
541         (equivalently_constrained): New.
542         (more_constraints): New.
543         (more_constrained): New.
544         (diagnose_constraints_failure): New.
545         * gcc/cp/cxx-pretty-print.c (pp_cxx_template_declaration): Print the
546         template requirements.
547         * gcc/cp/pt.c (local_specialization_stack): New.
548         (build_template_info): Refactor into 3-argument version and 
549         incorporate template requirements.
550         (check_explicit_specialization): Instantiate requirements for
551         template info.
552         (push_template_decl_real): Include constraints in template info.
553         (redeclare_class_template): Diagnose redeclaration with different
554         constraints.
555         (is_compatible_template_arg): New.
556         (convert_template_argument): Check constraints on template template
557         arguments and diagnose errors.
558         (lookup_template_class_1): Check constraints on alias templates.
559         Keep constraints with instantiated types.
560         (instantiate_class_template_1): Check constraints on class templates.
561         (tsubst_decl): Instantiate and keep constraints with template info.
562         Also, allow dependent pack arguments to produce neww parameter
563         packs when instantiated.
564         (coerce_template_parms): New overload.
565         (tsubst_copy): Handle REAL_TYPE and BOOLEAN_TYPE.
566         (tsubst_copy_and_build): PARM_DECLs can be instantiated as pack
567         expansions (used with requires expression).
568         (fn_type_unification): Check constraints for function templates.
569         (more_specialized_fn): Determine which candidate is more constrained.
570         (substitute_template_parameters): Removed.
571         (tsubst_constraint): New.
572         (substitute_requirements): New.
573         * gcc/cp/parser.c: (cp_parser_optional) Removed along with helper
574         functions, etc.
575         (cp_unevaluated): New.
576         (cp_parser_type_parameter): Check for requires kw explicitly, and
577         save/clear template requirements before parsing the requires clause.
578         (cp_parser_requires_clause): Removed.
579         (cp_parser_template_declaration_after_exp): Check for requires kw
580         explicitly.
581         * gcc/system.h (cstdlib): Removed include.
582         * gcc/c-family/c-common.h (D_CXX_CONCEPTS): New flag for disabling
583         concept keywords.
584         * gcc/c-family/c.opt (flag_concepts): Remove redundant declaration.
585         * gcc/c-family/c-common.c (c_common_r): Concept-specific keywords
586         are only enabled when concepts are enabled.
588 2013-06-01  Andrew Sutton  <andrew.n.sutton@gmail.com>
589         * gcc/system.h (cstdlib): Include <cstdlib> to avoid poisoned
590         declaration errors.
591         * gcc/c-family/common.c (c_common_r): Added __is_same_as intrinsic,
592         removed previous, unused intrinsics.
593         * gcc/c-family/common.h (rid): Added RID_IS_SAME_AS.
594         * gcc/cp/parser.c (take): New.
595         (cp_requires_clause): New.
596         (cp_requires_clause_opt): New.
597         (cp_rule): New.
598         (cp_parser_optional_if_token): New.
599         (cp_parser_optional_if_not_token): New.
600         (cp_parser_optional_if_keyword): New.
601         (cp_parser_decl_specifier_seq): Parse 'concept' as a declspec.
602         (cp_parser_type_parameter): Parse constrained template template parms.
603         (cp_parser_member_specification_opt): Parse member constraints after
604         the declaration, not before.
605         (cp_parser_template_declaration_after_exp): Rewrote parsing for
606         template requirements
607         (cp_parser_late_parsing_for_member): Re-push the current template 
608         requirements when late-parsing member definitions.
609         * gcc/cp/decl.c (check_concept_fn): New.
610         (grokfndecl): Semantics for concept declspec.
611         (grokdeclarator): Semantics for concept declspec.
612         (xref_tag_1): Update to new interface.
613         * gcc/cp/constraint.cc (make_constraints): New.
614         * gcc/cp/cp-objcp-common.c (cp_tree_size): Add case for constraint_info.
615         * gcc/cp/cp-tree.h (require): New.
616         (tree_template_info): Add a field for constraint info.
617         (tree_constraint_info): New.
618         (constraint_info_p): New.
619         (template_info_p): New.
620         (CI_SPELLING): New.
621         (CI_REQUIREMENTS): New.
622         (CI_ASSUMPTIONS): New.
623         (TI_CONSTRAINT): New.
624         (TI_SPELLING): New.
625         (TI_REQUIREMENTS): New.
626         (TI_ASSUMPTIONS): New.
627         (DECL_TEMPLATE_CONSTRAINT): New.
628         (CLASSTYPE_TEMPLATE_CONSTRAINT): New.
629         (ENUM_TEMPLATE_CONSTRAINT): New.
630         (TEMPLATE_TEMPLATE_PARM_TEMPLATE_CONSTRAINT): New.
631         (TYPE_TEMPLATE_CONSTRAINT): New.
632         (cp_tree_node_structure_enum): Added entry for constraint info.
633         (lang_tree_node): Added entry for constraint info.
634         (lang_decl_base): Added bit for concept declarations.
635         (DECL_DECLARED_CONCEPT_P): New.
636         (cp_decl_spec): Added ds_concept declaration specifier.
637         * gcc/cp/Make-lang.in (logic.o): New target.
638         * gcc/cp/semantics.c (finish_template_requirements): Rewrite.
639         * gcc/cp/logic.cc: New
640         * gcc/cp-tree.def (CONSTRAINT_INFO): New node.
641         * gcc/cp/pt.c (current_template_args): Make non-static.
642         (redeclare_class_template): Take constraints as a 3rd argument
644 2013-04-01  Andrew Sutton  <andrew.n.sutton@gmail.com>
645         
646         * gcc/cp/Make-lang.in: Add constraints.o target.
647         * gcc/cp/cp-tree.h (substitute_template_parameters): Declare.
648         (instantiate_requirements): Declare.
649         (conjoin_requirements): Declare.
650         (disjoin_requirements): Declare.
651         (reduce_requirements): Declare.
652         * gcc/cp/pt.c (substitute_template_parameters): Define.
653         (instantiate_requirements): Define.
654         * gcc/cp/pt.c (finish_template_requirements): Call
655         reduce_requirements to get constraints.
656         * gcc/cp/parser.c (cp_parser_type_parameter): Restore saved
657         constraints after parsing template template parameter decl.
658         * gcc/cp/constraints.cc: New.
660 2013-03-11  Andrew Sutton  <andrew.n.sutton@gmail.com>
661         * gcc/cp/Make-lang.in: Add constraint.c
662         * gcc/cp/constraint.c: New
663         (conjoin_requirements): New
664         (disjoin_requirements): New
665         (requirement_reduction): New class
666         (reduce_requirements): New
667         * gcc/cp/cp-tree.h (reduce_requrements): New
668         (conjoin_requirements): New
669         (disjoin_requirements): New
670         * gcc/cp/cp-tree.h (finish_template_template_parm) Comments.
671         * gcc/cp/semantics.c (finish_template_requirements) Start
672         working with requirements.
675 2013-03-01  Andrew Sutton  <andrew.n.sutton@gmail.com>
677         * gcc/cp/cp-tree.h (saved_scope): Add template requirements.
678         (finish_template_requirements): Declare
679         * gcc/cp/parser.c (cp_parser_template_requirement_opt): Declare.
680         (cp_parser_template_declaration): Document grammar extensions.
681         (cp_parser_type_parameter): Parse requirements for template
682         template parameters.
683         (cp_parser_member_declaration): Parse requirements for
684         members of class templates.
685         (cp_parser_template_requirement_opt): Define.
686         (cp_parser_template_declaration_after_exp): Parse requirements
687         for template declarations.
688         * gcc/cp/semantics.c (finish_template_requirements): Define.
689         * gcc/cp/lex.c (cxx_init): Enable concepts by default.
691 2013-03-01  Gabriel Dos Reis  <gdr@integrable-solutions.net>
693         * lex.c (flag_concepts): Revert left over declaration.
695 2013-03-01  Gabriel Dos Reis  <gdr@integrable-solutions.net>
697         * gcc/c-family/c-common.c (cxx_dialect): Set C++11 as default.
698         * gcc/c-family/c.opt(flag_concepts): Add.
699         * gcc/cp/lex.c (flag_concepts): New.  Enabled concept support by
700         default.
702 2013-02-28  Andrew Sutton  <andrew.n.sutton@gmail.com>
704         * gcc/c-family/c-common.h (rid): New resreserved words for concepts.
705         * gcc/c-family/c-common.c (c_common_reswords): Definitions thereof.
706         * gcc/doc/extend.texi (write_symbol): Initial concept docs.