public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [c++-concepts] Merge from trunk
@ 2013-04-15 12:44 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-04-15 12:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: andrew.n.sutton


Trunk as been merged into the c++-concepts branch.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] merge from trunk
@ 2014-11-13 17:05 Andrew Sutton
  0 siblings, 0 replies; 16+ messages in thread
From: Andrew Sutton @ 2014-11-13 17:05 UTC (permalink / raw)
  To: gcc-patches, Jason Merrill, Braden Obrzut

I just merged the concepts branch with trunk, after fighting with the
testing framework for the past hour. There was a change to

gcc/testsuite/lib/prune.exp

yesterday that doesn't appear to be compatible with *something* in
this branch. It broke the entire test suite, giving the errors below
for every .exp file.

Using /home/faculty/asutton/local/share/dejagnu/baseboards/unix.exp as
board description file for target.
Using /home/faculty/asutton/local/share/dejagnu/config/unix.exp as
generic interface file for target.
Using /home/faculty/asutton/Code/gcc/c++-concepts/gcc/testsuite/config/default.exp
as tool-and-target-specific interface file.
Running /home/faculty/asutton/Code/gcc/c++-concepts/gcc/testsuite/gcc.c-torture/compile/compile.exp
...
ERROR: tcl error sourcing
/home/faculty/asutton/Code/gcc/c++-concepts/gcc/testsuite/gcc.c-torture/compile/compile.exp.
ERROR: couldn't compile regular expression pattern: quantifier operand invalid
    while executing
"regsub -all "$srcdir\/" $text "" text"
    (procedure "prune_gcc_output" line 50)
    invoked from within
"prune_gcc_output $text"
    (procedure "gcc-dg-prune" line 8)
    invoked from within
"${tool}-dg-prune $target_triplet $comp_output"
    (procedure "saved-dg-test" line 183)
    invoked from within
"saved-dg-test /home/faculty/asutton/Code/gcc/c++-concepts/gcc/testsuite/gcc.c-torture/compile/20000105-1.c
{  -O0 } -w"
    ("eval" body line 1)
    invoked from within
"eval saved-dg-test $args "
    (procedure "dg-test" line 11)
    invoked from within
"dg-test $test "$flags $flags_t" ${default-extra-flags}"
    (procedure "gcc-dg-runtest" line 33)
    invoked from within
"gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" "-w""
    (file "/home/faculty/asutton/Code/gcc/c++-concepts/gcc/testsuite/gcc.c-torture/compile/compile.exp"
line 30)
    invoked from within
"source /home/faculty/asutton/Code/gcc/c++-concepts/gcc/testsuite/gcc.c-torture/compile/compile.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source
/home/faculty/asutton/Code/gcc/c++-concepts/gcc/testsuite/gcc.c-torture/compile/compile.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

I removed the offending line of code in this branch just to make the tests run.

That change does not affect any other builds on my system, so
something isn't being configured correctly. I just can't find what it
is.

Andrew

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] merge from trunk
@ 2013-09-09 13:13 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-09-09 13:13 UTC (permalink / raw)
  To: Andrew Sutton; +Cc: gcc-patches


at revision 202396.  No conflict.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] MErge from trunk
@ 2013-08-26 10:12 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-08-26 10:12 UTC (permalink / raw)
  To: Andrew Sutton; +Cc: gcc-patches


at revision 201992.
There were conflicts with the recent pretty printing patches.
Fixed.  (Mostly due to the new concept-specific nodes printing.)
Modulo the asan stuff.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] Merge from trunk
@ 2013-08-19  4:27 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-08-19  4:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Sutton


The c++-concepts branch was synchronized with trunk at revision 201834.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] Merge from trunk
@ 2013-08-07 11:36 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-08-07 11:36 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Sutton


trunk was merged into c++-concepts branch at revision 201560.
I resolved some conflicts in cp caused by recent merges and ongoing work
on trunk.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] Merge from trunk
@ 2013-07-15 17:26 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-07-15 17:26 UTC (permalink / raw)
  To: andrew.n.sutton; +Cc: jason, gcc-patches


Trunk was merged to the c++-concept branch at revision 200958.

Andrew --
There aere a few conflicts surronding introduction of
can_convert_standard, between your version and the one Jason committed.
I resolved them in favour of Jason's because his version followed the
GNU coding convention (when a binary expression spans several lines, the
binary operator starts the new line, etc.)

The split of cp/semantics.c into cp/lambda.c and the rest introduced a
conflict at the Makefile level.  Resolved.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] requires expressions
@ 2013-07-11 22:37 Andrew Sutton
  2013-07-12 19:25 ` Jason Merrill
  0 siblings, 1 reply; 16+ messages in thread
From: Andrew Sutton @ 2013-07-11 22:37 UTC (permalink / raw)
  To: gcc-patches, Gabriel Dos Reis, Jason Merrill

[-- Attachment #1: Type: text/plain, Size: 1830 bytes --]

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.sutton@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.

[-- Attachment #2: reqexpr-6.patch --]
[-- Type: application/octet-stream, Size: 19495 bytes --]

Index: pt.c
===================================================================
--- pt.c	(revision 200908)
+++ pt.c	(working copy)
@@ -13598,6 +13598,136 @@ tsubst_non_call_postfix_expression (tree
   return t;
 }
 
+// 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)
+{
+  if (!sparms)
+    return sparms;
+
+  tree p = TREE_CHAIN (sparms);
+  tree q = sparms;
+  while (p && TREE_VALUE (p) != void_type_node)
+    {
+      DECL_CHAIN (TREE_VALUE (q)) = TREE_VALUE (p);
+      q = p;
+      p = TREE_CHAIN (p);
+    }
+  return sparms;
+}
+
+// Register local specializations for each of tparm and the corresponding
+// sparm. This is a helper function for tsubst_requires_expr.
+void
+declare_local_parms (tree tparms, tree sparms)
+{
+  tree s = TREE_VALUE (sparms);
+  for (tree p = tparms; p && !VOID_TYPE_P (TREE_VALUE (p)); p = TREE_CHAIN (p))
+    {
+      tree t = TREE_VALUE (p);
+      if (FUNCTION_PARAMETER_PACK_P (t))
+        {
+          tree pack = extract_fnparm_pack (t, &s);
+          register_local_specialization (pack, t);
+        }
+      else 
+        {
+          register_local_specialization (s, t);
+          s = TREE_CHAIN (s);
+        }      
+    }
+}
+
+static tree
+tsubst_local_parms (tree t,
+                    tree args, 
+                    tsubst_flags_t complain, 
+                    tree in_decl)
+{
+  tree r = fix_local_parms (tsubst (t, args, complain, in_decl));
+  if (r == error_mark_node)
+    return error_mark_node;
+
+  // Register the instantiated args as local parameters.
+  if (t)
+    declare_local_parms (t, r);
+  
+  return r;
+}
+
+static tree
+tsubst_requirement_body (tree t, tree args, tree in_decl)
+{
+  cp_unevaluated guard;
+  tree r = NULL_TREE;
+  while (t)
+    {
+      // If any substitutions fail, then this is equivalent to
+      // returning false.
+      tree e = tsubst_expr (TREE_VALUE (t), args, tf_none, in_decl, false);
+      if (e == error_mark_node)
+        e = boolean_false_node;
+      r = tree_cons (NULL_TREE, e, r);
+      t = TREE_CHAIN (t);
+    }
+  return r;
+}
+
+static tree
+tsubst_requires_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
+{
+  local_specialization_stack stack;
+  tree p = tsubst_local_parms (TREE_OPERAND (t, 0), args, complain, in_decl);
+  tree r = tsubst_requirement_body (TREE_OPERAND (t, 1), args, in_decl);
+  return finish_requires_expr (p, r);
+}
+
+static tree
+tsubst_validexpr_expr (tree t, tree args, tree in_decl)
+{
+  tree r = tsubst_expr (TREE_OPERAND (t, 0), args, tf_none, in_decl, false);
+  return finish_validexpr_expr (r);
+}
+
+static tree
+tsubst_validtype_expr (tree t, tree args, tree in_decl)
+{
+  tree r = tsubst (TREE_OPERAND (t, 0), args, tf_none, in_decl);
+  return finish_validtype_expr (r);
+}
+
+static tree
+tsubst_constexpr_expr (tree t, tree args, tree in_decl)
+{
+  tree r = tsubst_expr (TREE_OPERAND (t, 0), args, tf_none, in_decl, false);
+  return finish_constexpr_expr (r);
+}
+
+static tree
+tsubst_expr_req (tree t, tree args, tree in_decl)
+{
+  tree r = NULL_TREE;
+  for (tree l = TREE_OPERAND (t, 0); l; l = TREE_CHAIN (l))
+    {
+      tree e = tsubst_expr (TREE_VALUE (l), args, tf_none, in_decl, false);
+      r = conjoin_requirements (r, e);
+    }
+  return r;
+}
+
+static tree
+tsubst_type_req (tree t, tree args, tree in_decl)
+{
+  return tsubst_expr (TREE_OPERAND (t, 0), args, tf_none, in_decl, false);
+}
+
+static tree
+tsubst_nested_req (tree t, tree args, tree in_decl)
+{
+  return tsubst_expr (TREE_OPERAND (t, 0), args, tf_none, in_decl, false);
+}
+
 /* Like tsubst but deals with expressions and performs semantic
    analysis.  FUNCTION_P is true if T is the "F" in "F (ARGS)".  */
 
@@ -14775,6 +14905,31 @@ tsubst_copy_and_build (tree t,
     case PAREN_EXPR:
       RETURN (finish_parenthesized_expr (RECUR (TREE_OPERAND (t, 0))));
 
+    case REQUIRES_EXPR:
+      RETURN (tsubst_requires_expr (t, args, complain, in_decl));
+
+    case VALIDEXPR_EXPR:
+      RETURN (tsubst_validexpr_expr (t, args, in_decl));
+    
+    case VALIDTYPE_EXPR:
+      RETURN (tsubst_validtype_expr (t, args, in_decl));
+
+    case CONSTEXPR_EXPR:
+      RETURN (tsubst_constexpr_expr (t, args, in_decl));
+
+    // Normally, *_REQ are reduced out of requiremetns when used
+    // as constraints. If a concept is checked directly via e.g.,
+    // a static_assert, however, these appear in the input tree.
+
+    case EXPR_REQ:
+      RETURN (tsubst_expr_req (t, args, in_decl));
+
+    case TYPE_REQ:
+      RETURN (tsubst_type_req (t, args, in_decl));
+
+    case NESTED_REQ:
+      RETURN (tsubst_nested_req (t, args, in_decl));
+
     default:
       /* Handle Objective-C++ constructs, if appropriate.  */
       {
@@ -21325,7 +21480,7 @@ print_template_statistics (void)
 tree
 instantiate_requirements (tree reqs, tree args)
 {
-  return tsubst_expr (reqs, args, tf_none, NULL_TREE, true);
+  return tsubst_expr (reqs, args, tf_none, NULL_TREE, false);
 }
 
 // Create a new constraint info block by substituting ARGS into
Index: constraint.cc
===================================================================
--- constraint.cc	(revision 200584)
+++ constraint.cc	(working copy)
@@ -188,6 +188,10 @@ static tree reduce_misc (tree);
 
 static tree reduce_logical     (tree);
 static tree reduce_call        (tree);
+static tree reduce_requires    (tree);
+static tree reduce_expr_req    (tree);
+static tree reduce_type_req    (tree);
+static tree reduce_nested_req  (tree);
 static tree reduce_template_id (tree);
 static tree reduce_stmt_list   (tree);
 
@@ -238,6 +242,18 @@ reduce_expr (tree t)
     case CALL_EXPR:        
       return reduce_call (t);
 
+    case REQUIRES_EXPR:
+      return reduce_requires (t);
+
+    case EXPR_REQ:
+      return reduce_expr_req (t);
+
+    case TYPE_REQ:
+      return reduce_type_req (t);
+
+    case NESTED_REQ:
+      return reduce_nested_req (t);
+
     case TEMPLATE_ID_EXPR: 
       return reduce_template_id (t);
 
@@ -389,6 +405,43 @@ reduce_template_id (tree t)
   return NULL_TREE;
 }
 
+
+// Reduce an expression requirement as a conjunction of its
+// individual constraints.
+tree
+reduce_expr_req (tree t) 
+{
+  tree r = NULL_TREE;
+  for (tree l = TREE_OPERAND (t, 0); l; l = TREE_CHAIN (l))
+    r = conjoin_requirements (r, reduce_expr (TREE_VALUE (l)));
+  return r;
+}
+
+// Reduce a type requirement by returing its underlying
+// constraint.
+tree
+reduce_type_req (tree t) 
+{
+  return TREE_OPERAND (t, 0);
+}
+
+// Reduce a nested requireemnt by returing its only operand.
+tree
+reduce_nested_req (tree t) 
+{
+  return TREE_OPERAND (t, 0);
+}
+
+// Reduce a requires expr by reducing each requirement in turn,
+// rewriting the list of requirements.
+tree
+reduce_requires (tree t)
+{
+  for (tree l = TREE_OPERAND (t, 1); l; l = TREE_CHAIN (l))
+    TREE_VALUE (l) = reduce_expr (TREE_VALUE (l));
+  return t;
+}
+
 // Reduction rules for the statement list STMTS.
 //
 // Recursively reduce each statement in the list, concatenating each
@@ -405,12 +458,7 @@ reduce_stmt_list (tree stmts)
   while (!tsi_end_p (i))
     {
       if (tree rhs = reduce_node (tsi_stmt (i)))
-        {
-          if (!lhs)
-            lhs = rhs;
-          else
-            lhs = conjoin_requirements (lhs, rhs);
-        }
+        lhs = conjoin_requirements (lhs, rhs);
       tsi_next (&i);
     }
   return lhs;
@@ -481,9 +529,7 @@ get_constraints (tree t)
 static inline bool
 check_requirements (tree reqs)
 {
-  // Simplify the expression before evaluating it. This will
-  // cause TRAIT_EXPR nodes to be reduced before constexpr
-  // evaluation.
+  // Reduce any remaining TRAIT_EXPR nodes before evaluating.
   reqs = fold_non_dependent_expr (reqs);
   
   // Requirements are satisfied when REQS evaluates to true.
@@ -702,6 +748,78 @@ diagnose_call (location_t loc, tree t, t
     inform (loc, "  %qE evaluated to false", t);
 }
 
+// Diagnose specific constraint failures.
+void
+diagnose_requires (location_t loc, tree t, tree args)
+{
+  if (check_requirements (t, args))
+    return;
+
+  ++processing_template_decl;
+  tree subst = instantiate_requirements (t, args);
+  --processing_template_decl;
+
+  // Print the header for the requires expression.
+  tree parms = TREE_OPERAND (subst, 0);
+  if (!VOID_TYPE_P (TREE_VALUE (parms)))
+    inform (loc, "  requiring syntax with values %Z", TREE_OPERAND (subst, 0));
+
+  // Create a new local specialization binding for the arguments. 
+  // This lets us instantiate sub-expressions separately from the 
+  // requries clause.
+  local_specialization_stack locals;
+  declare_local_parms (TREE_OPERAND (t, 0), TREE_OPERAND (subst, 0));
+
+  // Iterate over the sub-requirements and try instantiating each.
+  for (tree l = TREE_OPERAND (t, 1); l; l = TREE_CHAIN (l))
+    diagnose_node (loc, TREE_VALUE (l), args);
+}
+
+static void
+diagnose_validexpr (location_t loc, tree t, tree args)
+{
+  if (check_requirements (t, args))
+    return;
+  inform (loc, "    %qE is not valid syntax", TREE_OPERAND (t, 0));
+}
+
+static void
+diagnose_validtype (location_t loc, tree t, tree args)
+{
+  if (check_requirements (t, args))
+    return;
+
+  // Substitute into the qualified name.
+  tree name = TREE_OPERAND (t, 0);
+  if (tree cxt = TYPE_CONTEXT (name))
+    {
+      tree id = TYPE_IDENTIFIER (name);
+      cxt = tsubst (cxt, args, tf_none, NULL_TREE);
+      name = build_qualified_name (NULL_TREE, cxt, id, false);
+      inform (loc, "    %qE does not name a valid type", name);
+    }
+  else
+    {
+      inform (loc, "    %qT does not name a valid type", name);
+    }
+}
+
+static void
+diagnose_constexpr (location_t loc, tree t, tree args)
+{
+  if (check_requirements (t, args))
+    return;
+  inform (loc, "    %qE is not a constant expression", TREE_OPERAND (t, 0));
+}
+
+static void
+diagnose_noexcept (location_t loc, tree t, tree args)
+{
+  if (check_requirements (t, args))
+    return;
+  inform (loc, "    %qE propagates exceptions", TREE_OPERAND (t, 0)); 
+}
+
 // Diagnose a constraint failure in the expression T.
 void
 diagnose_other (location_t loc, tree t, tree args)
@@ -730,9 +848,31 @@ diagnose_node (location_t loc, tree t, t
     case TRAIT_EXPR:
       diagnose_trait (loc, t, args);
       break;
+    
     case CALL_EXPR:
       diagnose_call (loc, t, args);
       break;
+
+    case REQUIRES_EXPR:
+      diagnose_requires (loc, t, args);
+      break;
+
+    case VALIDEXPR_EXPR:
+      diagnose_validexpr (loc, t, args);
+      break;
+    
+    case VALIDTYPE_EXPR:
+      diagnose_validtype (loc, t, args);
+      break;
+    
+    case CONSTEXPR_EXPR:
+      diagnose_constexpr (loc, t, args);
+      break;
+
+    case NOEXCEPT_EXPR:
+      diagnose_noexcept (loc, t, args);
+      break;
+
     default:
       diagnose_other (loc, t, args);
       break;
Index: cxx-pretty-print.c
===================================================================
--- cxx-pretty-print.c	(revision 200908)
+++ cxx-pretty-print.c	(working copy)
@@ -480,6 +480,18 @@ pp_cxx_primary_expression (cxx_pretty_pr
       pp_cxx_nested_requirement (pp, t);
       break;
 
+    case VALIDEXPR_EXPR:
+      pp_cxx_validexpr_expr (pp, t);
+      break;
+
+    case VALIDTYPE_EXPR:
+      pp_cxx_validtype_expr (pp, t);
+      break;
+
+    case CONSTEXPR_EXPR:
+      pp_cxx_constexpr_expr (pp, t);
+      break;
+
     default:
       pp_c_primary_expression (pp_c_base (pp), t);
       break;
@@ -2486,28 +2498,27 @@ static void
 pp_cxx_requirement_body (cxx_pretty_printer *pp, tree t)
 {
   pp_cxx_left_brace (pp);
-  pp_cxx_requirement_list (pp, TREE_OPERAND (t, 1));
+  pp_cxx_requirement_list (pp, t);
   pp_cxx_right_brace (pp);
 }
 
 // requirement-parameter-list:
 //    '(' parameter-declaration-clause ')'
-static void
+void
 pp_cxx_requirement_parameter_list (cxx_pretty_printer *pp, tree t)
 {
-  tree p = TREE_OPERAND (t, 0);
-  pp_left_paren (pp);
-  while (p)
+  pp_cxx_left_paren (pp);
+  while (t && !VOID_TYPE_P (TREE_VALUE (t)))
     {
-      tree parm = TREE_VALUE (p);
+      tree parm = TREE_VALUE (t);
       pp_cxx_parameter_declaration (pp, parm);
-      if (!VOID_TYPE_P (TREE_VALUE (TREE_CHAIN (p))))
+      if (!VOID_TYPE_P (TREE_VALUE (TREE_CHAIN (t))))
         pp_separate_with (pp, ',');
       else
         break;
-      p = TREE_CHAIN (p);
+      t = TREE_CHAIN (t);
     }
-  pp_right_paren (pp);
+  pp_cxx_right_paren (pp);
 }
 
 // requires-expression:
@@ -2517,9 +2528,9 @@ pp_cxx_requires_expr (cxx_pretty_printer
 {
   pp_cxx_ws_string (pp, "requires");
   pp_space (pp);
-  pp_cxx_requirement_parameter_list (pp, t);
+  pp_cxx_requirement_parameter_list (pp, TREE_OPERAND (t, 0));
   pp_space (pp);
-  pp_cxx_requirement_body (pp, t);
+  pp_cxx_requirement_body (pp, TREE_OPERAND (t, 1));
 }
 
 // constraint-specifier:
@@ -2627,6 +2638,33 @@ pp_cxx_nested_requirement (cxx_pretty_pr
   pp_cxx_semicolon (pp);
 }
 
+void
+pp_cxx_validexpr_expr (cxx_pretty_printer *pp, tree t)
+{
+  pp_cxx_ws_string (pp, "__is_valid_expr");
+  pp_cxx_left_paren (pp);
+  pp_cxx_expression (pp, TREE_OPERAND (t, 0));
+  pp_cxx_right_paren (pp);
+}
+
+void
+pp_cxx_validtype_expr (cxx_pretty_printer *pp, tree t)
+{
+  pp_cxx_ws_string (pp, "__is_valid_expr");
+  pp_cxx_left_paren (pp);
+  pp_cxx_type_id (pp, TREE_OPERAND (t, 0));
+  pp_cxx_right_paren (pp);
+}
+
+void
+pp_cxx_constexpr_expr (cxx_pretty_printer *pp, tree t)
+{
+  pp_cxx_ws_string (pp, "__is_valid_expr");
+  pp_cxx_left_paren (pp);
+  pp_cxx_expression (pp, TREE_OPERAND (t, 0));
+  pp_cxx_right_paren (pp);
+}
+
 \f
 typedef c_pretty_print_fn pp_fun;
 
Index: cxx-pretty-print.h
===================================================================
--- cxx-pretty-print.h	(revision 200908)
+++ cxx-pretty-print.h	(working copy)
@@ -76,10 +76,14 @@ void pp_cxx_trait_expression (cxx_pretty
 void pp_cxx_va_arg_expression (cxx_pretty_printer *, tree);
 void pp_cxx_offsetof_expression (cxx_pretty_printer *, tree);
 void pp_cxx_userdef_literal (cxx_pretty_printer *, tree);
+void pp_cxx_requirement_parameter_list (cxx_pretty_printer *, tree);
 void pp_cxx_requires_expr (cxx_pretty_printer *, tree);
 void pp_cxx_expr_requirement (cxx_pretty_printer *, tree);
 void pp_cxx_type_requirement (cxx_pretty_printer *, tree);
 void pp_cxx_nested_requirement (cxx_pretty_printer *, tree);
+void pp_cxx_validexpr_expr (cxx_pretty_printer *, tree);
+void pp_cxx_validtype_expr (cxx_pretty_printer *, tree);
+void pp_cxx_constexpr_expr (cxx_pretty_printer *, tree);
 
 
 #endif /* GCC_CXX_PRETTY_PRINT_H */
Index: error.c
===================================================================
--- error.c	(revision 200908)
+++ error.c	(working copy)
@@ -2589,6 +2589,17 @@ dump_expr (tree t, int flags)
       pp_cxx_nested_requirement (cxx_pp, t);
       break;
 
+    case VALIDEXPR_EXPR:
+      pp_cxx_validexpr_expr (cxx_pp, t);
+      break;
+
+    case VALIDTYPE_EXPR:
+      pp_cxx_validtype_expr (cxx_pp, t);
+      break;
+    
+    case CONSTEXPR_EXPR:
+      pp_cxx_constexpr_expr (cxx_pp, t);
+
       /*  This list is incomplete, but should suffice for now.
 	  It is very important that `sorry' does not call
 	  `report_error_function'.  That could cause an infinite loop.  */
@@ -2908,7 +2919,7 @@ args_to_string (tree p, int verbose)
   int flags = 0;
   if (verbose)
     flags |= TFF_CLASS_KEY_OR_ENUM;
-
+  
   if (p == NULL_TREE)
     return "";
 
@@ -2968,6 +2979,14 @@ cv_to_string (tree p, int v)
   return pp_formatted_text (cxx_pp);
 }
 
+static const char*
+reqparms_to_string (tree p)
+{
+  reinit_cxx_pp ();
+  pp_cxx_requirement_parameter_list (cxx_pp, p);
+  return pp_formatted_text (cxx_pp);
+}
+
 
 /* Langhook for print_error_function.  */
 void
@@ -3400,6 +3419,7 @@ cp_printer (pretty_printer *pp, text_inf
     case 'K':
       percent_K_format (text);
       return true;
+    case 'Z': result = reqparms_to_string (next_tree);          break;
 
     default:
       return false;
Index: cp-tree.h
===================================================================
--- cp-tree.h	(revision 200908)
+++ cp-tree.h	(working copy)
@@ -5649,6 +5649,7 @@ extern tree coerce_template_parms
 extern tree instantiate_requirements            (tree, tree);
 extern tree tsubst_constraint                   (tree, tree);
 extern tree current_template_args               ();
+extern void declare_local_parms                 (tree, tree);
 
 /* in repo.c */
 extern void init_repo				(void);
@@ -5809,7 +5810,7 @@ extern tree finish_nested_requirement
 extern tree finish_constexpr_requirement        (tree);
 extern tree finish_noexcept_requirement         (tree);
 extern tree finish_validexpr_expr               (tree);
-extern tree finish_validtype_epxr               (tree);
+extern tree finish_validtype_expr               (tree);
 extern tree finish_constexpr_expr               (tree);
 
 enum {
Index: semantics.c
===================================================================
--- semantics.c	(revision 200908)
+++ semantics.c	(working copy)
@@ -8466,6 +8466,13 @@ potential_constant_expression_1 (tree t,
     case FIELD_DECL:
     case PARM_DECL:
     case USING_DECL:
+    case REQUIRES_EXPR:
+    case EXPR_REQ:
+    case TYPE_REQ:
+    case NESTED_REQ:
+    case VALIDEXPR_EXPR:
+    case VALIDTYPE_EXPR:
+    case CONSTEXPR_EXPR:
       return true;
 
     case AGGR_INIT_EXPR:
@@ -10021,10 +10028,8 @@ finish_template_requirements (tree expr)
     return make_constraints (expr);
 }
 
-// Finish a requires expression, returning a node wrapping the parameters,
-// PARMS, and the list of requirements REQS.
 tree
-finish_requires_expr (tree parms, tree reqs)
+build_requires_expr (tree parms, tree reqs)
 {
   // Modify the declared parameters by removing their context (so they
   // don't refer to the enclosing scope), and marking them constant (so
@@ -10043,6 +10048,32 @@ finish_requires_expr (tree parms, tree r
   return r;
 }
 
+// Evaluate an instantiatd requires expr, returning the truth node
+// only when all sub-requirements have evaluated to true.
+tree
+eval_requires_expr (tree reqs)
+{
+  for (tree t = reqs ; t; t = TREE_CHAIN (t)) {
+    tree r = TREE_VALUE (t);
+    r = fold_non_dependent_expr (r);
+    r = maybe_constant_value (r);
+    if (r != boolean_true_node)
+      return boolean_false_node;
+  }
+  return boolean_true_node;
+}
+
+// Finish a requires expression, returning a node wrapping the parameters,
+// PARMS, and the list of requirements REQS.
+tree
+finish_requires_expr (tree parms, tree reqs)
+{
+  if (processing_template_decl)
+    return build_requires_expr (parms, reqs);
+  else
+    return eval_requires_expr (reqs);
+}
+
 // Construct a unary expression that evaluates properties of the
 // expression or type T, and has a boolean result type.
 static inline tree
@@ -10115,7 +10146,7 @@ tree
 finish_type_requirement (tree type)
 {
   gcc_assert (processing_template_decl);
-  tree req = finish_validtype_epxr (type);
+  tree req = finish_validtype_expr (type);
   return build_check_expr (TYPE_REQ, req);
 }
 
@@ -10171,7 +10202,7 @@ finish_validexpr_expr (tree expr)
 // When processing a template declaration, the result is an expression 
 // representing the check.
 tree
-finish_validtype_epxr (tree type)
+finish_validtype_expr (tree type)
 {
   if (processing_template_decl)
     return build_check_expr (VALIDTYPE_EXPR, type);

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] Merge from trunk
@ 2013-06-22 22:27 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-06-22 22:27 UTC (permalink / raw)
  To: andrew.n.sutton; +Cc: gcc-patches


Andrew -- 

At revision 200343.

With the merge of Cilk changes to trunk, it was necessary to synchronize
so that c++-concepts branch doesn't get too out of sync.  There were a
few conflicts in cp/Make-lang.in and cp/cp-tree.h that I think I
resolved properly.  Let me know if anything else was lost (I think not.)


-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] merge from trunk
@ 2013-06-21  3:12 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-06-21  3:12 UTC (permalink / raw)
  To: gcc-patches


At revision 200282.

Andrew -- 
there was a slight conflict with the new usage of is_binary_trait.
I think I resolved it properly, but double check.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] merge from trunk
@ 2013-05-16 18:49 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-05-16 18:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: andrew.n.sutton


Trunk was merged into c++-concepts branch at revision 198984.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] Merge from trunk
@ 2013-05-01 21:09 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-05-01 21:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: andrew.n.sutton


Trunk was merged into the c++-concept branch as of revision 198506.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] Merge from trunk
@ 2013-03-29  5:01 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-03-29  5:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: asutton


The trunk was merged into the c++-concepts branch as of revision 197225.

-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread
* [c++-concepts] Merge from trunk
@ 2013-03-21  7:41 Gabriel Dos Reis
  0 siblings, 0 replies; 16+ messages in thread
From: Gabriel Dos Reis @ 2013-03-21  7:41 UTC (permalink / raw)
  To: gcc-patches; +Cc: andrew.n.sutton


I've merged changes from trunk into the c++-concepts branch as of
revision 196857.  These include Jason's patch to stop randomness
in linkage name of entities defined at unnamed namespace scopes.


-- Gaby

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-11-13 17:04 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-15 12:44 [c++-concepts] Merge from trunk Gabriel Dos Reis
  -- strict thread matches above, loose matches on Subject: below --
2014-11-13 17:05 [c++-concepts] merge " Andrew Sutton
2013-09-09 13:13 Gabriel Dos Reis
2013-08-26 10:12 [c++-concepts] MErge " Gabriel Dos Reis
2013-08-19  4:27 [c++-concepts] Merge " Gabriel Dos Reis
2013-08-07 11:36 Gabriel Dos Reis
2013-07-15 17:26 Gabriel Dos Reis
2013-07-11 22:37 [c++-concepts] requires expressions Andrew Sutton
2013-07-12 19:25 ` Jason Merrill
2013-07-13 14:23   ` Andrew Sutton
2013-07-13 21:56     ` Jason Merrill
2013-07-25 14:25       ` Andrew Sutton
2013-07-25 19:49         ` Jason Merrill
2013-07-26 11:39           ` Andrew Sutton
2013-07-27  6:38             ` Gabriel Dos Reis
2013-07-27 11:33               ` Andrew Sutton
2013-07-27 14:30                 ` [c++-concepts] Merge from trunk Gabriel Dos Reis
2013-07-27 22:18                   ` Tom Tromey
2013-07-28  4:13                     ` Gabriel Dos Reis
2013-06-22 22:27 Gabriel Dos Reis
2013-06-21  3:12 [c++-concepts] merge " Gabriel Dos Reis
2013-05-16 18:49 Gabriel Dos Reis
2013-05-01 21:09 [c++-concepts] Merge " Gabriel Dos Reis
2013-03-29  5:01 Gabriel Dos Reis
2013-03-21  7:41 Gabriel Dos Reis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).