Re: [c++-concepts] requires expressions

2013-07-27 Thread Andrew Sutton
Committed.

On Fri, Jul 26, 2013 at 10:27 PM, Gabriel Dos Reis g...@axiomatics.org wrote:
 Andrew Sutton andrew.n.sut...@gmail.com writes:

 | Fixed and committed, but I have a small follow-up related to parameter
 | packs in requires clauses. The checking for unexpanded parameter packs
 | treats the parameter declarations like regular PARM_DECL references
 | and gives errors that they are unexpanded packs.
 |
 | 2013-07-26  Andrew Sutton  andrew.n.sut...@gmail.com
 | * gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
 | requires expr parameter list.
 |
 | Andrew

 Let me know when you commit this so I can merge from trunk.

 -- Gaby



-- 
Andrew Sutton
andrew.n.sut...@gmail.com


Re: [c++-concepts] requires expressions

2013-07-26 Thread Andrew Sutton
Fixed and committed, but I have a small follow-up related to parameter
packs in requires clauses. The checking for unexpanded parameter packs
treats the parameter declarations like regular PARM_DECL references
and gives errors that they are unexpanded packs.

2013-07-26  Andrew Sutton  andrew.n.sut...@gmail.com
* gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
requires expr parameter list.

Andrew


On Thu, Jul 25, 2013 at 3:49 PM, Jason Merrill ja...@redhat.com wrote:
 On 07/25/2013 10:19 AM, Andrew Sutton wrote:

 +  pp_cxx_parameter_declaration_clause(pp, TREE_OPERAND (t, 0));


 Space before (.  Otherwise, looks good.

 Jason




-- 
Andrew Sutton
andrew.n.sut...@gmail.com


requires-8.patch
Description: Binary data


Re: [c++-concepts] requires expressions

2013-07-26 Thread Jason Merrill

Makes sense.

Jason


Re: [c++-concepts] requires expressions

2013-07-26 Thread Gabriel Dos Reis
Andrew Sutton andrew.n.sut...@gmail.com writes:

| Fixed and committed, but I have a small follow-up related to parameter
| packs in requires clauses. The checking for unexpanded parameter packs
| treats the parameter declarations like regular PARM_DECL references
| and gives errors that they are unexpanded packs.
| 
| 2013-07-26  Andrew Sutton  andrew.n.sut...@gmail.com
| * gcc/cp/tree.c (cp_walk_subtrees): Don't recurse through the
| requires expr parameter list.
| 
| Andrew

Let me know when you commit this so I can merge from trunk.

-- Gaby


Re: [c++-concepts] requires expressions

2013-07-25 Thread Jason Merrill

On 07/25/2013 10:19 AM, Andrew Sutton wrote:

+  pp_cxx_parameter_declaration_clause(pp, TREE_OPERAND (t, 0));


Space before (.  Otherwise, looks good.

Jason



Re: [c++-concepts] requires expressions

2013-07-13 Thread Andrew Sutton
 This should be merged with pp_cxx_parameter_declaration_clause.

 +reqparms_to_string (tree p)


 And this should have a more generic name.

I called this parms_to_string for symmetry with args_to_string. It
calls pp_cxx_parameter_declaration_clause.


 +  if (check_requirements (t, args))
 +return;
 +
 +  ++processing_template_decl;
 +  tree subst = instantiate_requirements (t, args);
 +  --processing_template_decl;


 Surely you need to instantiate before checking, here and elsewhere.

check_requirements will instantiate before evaluating.

There are two instantiations on purpose. If checking succeeds, then
there are no failures in this branch of constraint, so we don't need
to recursively diagnose failures.

The second generates a possibly invalid tree that is useful for
emitting precise diagnostics, written in terms of the template
arguments. Basically, it means I can generate this message:

  'int::type' is not a valid type name.

for failed nested type requirements.


 +  inform (loc, %qE is not valid syntax, TREE_OPERAND (t, 0));


 I don't think I would mention syntax here, since a syntax error would have
 been diagnosed at parse time rather than constraint checking time.


is not a valid expression seems more appropriate.


 +// In an unevaluated context, the substitution of parm decls are not
 +// properly chained during substitution. Do that here.
 +static tree
 +fix_local_parms (tree sparms)

 

 A lot of the new code in pt.c doesn't seem like it needs to be there; let's
 put as much in constraint.cc as we can.  Let's move some of the bits out of
 semantics.c as well.

I think the [fixup|declare]_local_parms could move to semantics.c.
Would you recommend moving tsubst_* for requirements into
constraints.cc?


Andrew


Re: [c++-concepts] requires expressions

2013-07-13 Thread Jason Merrill

On 07/13/2013 05:37 AM, Andrew Sutton wrote:

There are two instantiations on purpose.


OK.


A lot of the new code in pt.c doesn't seem like it needs to be there; let's
put as much in constraint.cc as we can.  Let's move some of the bits out of
semantics.c as well.


I think the [fixup|declare]_local_parms could move to semantics.c.
Would you recommend moving tsubst_* for requirements into
constraints.cc?


Yes, but I was thinking that [fixup|declare]_local_parms would go to 
constraints.cc as well.  Both semantics.c and pt.c are too large already.


Jason



Re: [c++-concepts] requires expressions

2013-07-12 Thread Jason Merrill

On 07/11/2013 02:59 PM, Andrew Sutton wrote:

 pp_cxx_requirement_parameter_list (cxx_pretty_printer *pp, tree t)


This should be merged with pp_cxx_parameter_declaration_clause.


+reqparms_to_string (tree p)


And this should have a more generic name.


+  // requries clause.


requires


+  if (check_requirements (t, args))
+return;
+
+  ++processing_template_decl;
+  tree subst = instantiate_requirements (t, args);
+  --processing_template_decl;


Surely you need to instantiate before checking, here and elsewhere.


+  inform (loc, %qE is not valid syntax, TREE_OPERAND (t, 0));


I don't think I would mention syntax here, since a syntax error would 
have been diagnosed at parse time rather than constraint checking time.



+// In an unevaluated context, the substitution of parm decls are not
+// properly chained during substitution. Do that here.
+static tree
+fix_local_parms (tree sparms)



A lot of the new code in pt.c doesn't seem like it needs to be there; 
let's put as much in constraint.cc as we can.  Let's move some of the 
bits out of semantics.c as well.


Incidentally, I notice a funny thing about the headers of the new files:

/* Process declarations and variables for C++ compiler.
...
// Components for processing constraints and evaluating constraints.

The second line should move to the top of the file, replacing the first 
line.


Jason



[c++-concepts] requires expressions

2013-07-11 Thread Andrew Sutton
The attached patch finishes the semantics for requires expressions. It
includes reduction rules for constraint decomposition, substitution
rules, and diagnostics.

Andrew


Changelog:

2013-07-11  Andrew Sutton  andrew.n.sut...@gmail.com
* gcc/cp/cp-tree.h (declare_local_parms): New
* gcc/cp/cp-tree.h (finish_validtype_expr): Fixed typo.
* gcc/cp/semantics.c (potential_constant_expr): Return true for
 requirements.
(finish_requires_expr): Actually evaluate when we are not processing
a template decl.
* pt.c (tsubst_requires_expr): New, along with helper functions for
instantiating requires parameters.
(tsubst_validexpr_expr): New.
(tsubst_validtype_expr): New.
(tsubst_constexpr_expr): New.
(tsubst_expr_req): New.
(tsubst_type_req): New.
(tsubst_nested_req): New.
(tsubst_copy_and_build): Substitution rules for requirements.
(instantiate_requirements): Do not require a constant expression.
* constraint.cc (redcue_requires): Reduction rules for requires
expressions and requirement nodes.
(reduce_stmt_list): Remove redundant checks.
(diagnose_requires): Diagnose failures in requires expressions and
specific kinds of expressions.
* gcc/cp/cxx-pretty-print.c (pp_cxx_primary_expression): Pretty print
expressions related to requirements
(pp_cxx_requirement_parameter_list). Clean up implementation.
* gcc/cp/cxx-pretty-print.h (pp_cxx_requirement_parameter_list): New,
along with pretty printers for requirements-related expressions.
* gcc/cp/error.c (dump_expr): Dump expressions related to requirements.
(reqparms_to_string): New.
(cp_printer): Use %Z to print a list of parameters.


reqexpr-6.patch
Description: Binary data