public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 3/5] Add test cases for all the new cilk errors
  2014-10-02  4:28 ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Andi Kleen
@ 2014-10-02  4:28   ` Andi Kleen
  2014-10-02  4:28     ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Andi Kleen
  2014-10-02 18:01     ` [PATCH 3/5] Add test cases for all the new cilk errors Jeff Law
  2014-10-02 15:07   ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Joseph S. Myers
  1 sibling, 2 replies; 15+ messages in thread
From: Andi Kleen @ 2014-10-02  4:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

gcc/testsuite/:

2014-09-30  Andi Kleen  <ak@linux.intel.com>

	* c-c++-common/cilk-plus/CK/errors.c: New test.
---
 gcc/testsuite/c-c++-common/cilk-plus/CK/errors.c | 56 ++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 gcc/testsuite/c-c++-common/cilk-plus/CK/errors.c

diff --git a/gcc/testsuite/c-c++-common/cilk-plus/CK/errors.c b/gcc/testsuite/c-c++-common/cilk-plus/CK/errors.c
new file mode 100644
index 0000000..ca2032c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/CK/errors.c
@@ -0,0 +1,56 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int func_2(void);
+
+int check_spawn(int v)
+{
+  if (_Cilk_spawn func_2()) /* { dg-error "cannot contain" "" { target c } } */
+  /* XXX: no error in C++ */
+    ;
+  if (v + _Cilk_spawn func_2())  /* { dg-error "cannot contain" "" { target c } } */
+  /* { dg-error "invalid use" "" { target c++ } 11 } */
+    ;
+  if (v, _Cilk_spawn func_2()) /* { dg-error "spawned function call cannot be part" } */
+    ;
+  v, _Cilk_spawn func_2(); /* { dg-error "spawned function call cannot be part" } */
+  while (_Cilk_spawn func_2())  /* { dg-error "a condition for while statement" } */
+    ;
+  while (v + _Cilk_spawn func_2())  /* { dg-error "a condition for while statement" } */
+    ;
+  for (; _Cilk_spawn func_2() ;)  /* { dg-error "cannot be used" } */
+    ;
+  for (; v + _Cilk_spawn func_2() ;)  /* { dg-error "cannot be used" } */
+    ;
+  v + _Cilk_spawn func_2(); /* { dg-error } */
+  for (_Cilk_spawn func_2() ;;)
+    ;
+  for (;; _Cilk_spawn func_2())
+    ;
+  do {} while(_Cilk_spawn func_2());  /* { dg-error "cannot be used" } */
+  do {} while(v + _Cilk_spawn func_2());  /* { dg-error "cannot be used" } */
+  switch (_Cilk_spawn func_2())   /* { dg-error "cannot be used" } */
+    {
+    default: break;
+    }
+  goto *(_Cilk_spawn func_2()); /* { dg-error "cannot be used" } */
+
+  return _Cilk_spawn func_2(); /* { dg-error "is not allowed" } */
+}
+
+int check_array_notation(int x[100], int y[100])
+{
+  x[0:100] = y[0:100];
+  for (; x[0:100] = y[0:100]; )  /* { dg-error "cannot be used" } */
+    ;
+  while (x[0:100] = y[0:100])  /* { dg-error "cannot be used" } */
+    ;
+  switch (x[0:100] = y[0:100])  /* { dg-error "cannot be used" } */
+    {
+      default: break;
+    }
+  do {} while (x[0:100] = y[0:100]);  /* { dg-error "cannot be used" } */
+  if (x[0:100] = y[0:100]) /* allowed */
+    ;
+  return x[0:100] = y[0:100]; /* { dg-error "cannot be used" } */
+}
-- 
2.1.1

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

* [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places
  2014-10-02  4:28 [PATCH 1/5] Fix error location for cilk error message Andi Kleen
@ 2014-10-02  4:28 ` Andi Kleen
  2014-10-02  4:28   ` [PATCH 3/5] Add test cases for all the new cilk errors Andi Kleen
  2014-10-02 15:07   ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Joseph S. Myers
  2014-10-02 18:00 ` [PATCH 1/5] Fix error location for cilk error message Jeff Law
  1 sibling, 2 replies; 15+ messages in thread
From: Andi Kleen @ 2014-10-02  4:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

_Cilk_spawn or Cilk array expressions are only allowed on their own,
but not in for(), if(), switch, do, while, goto, etc.
The C parser didn't always check for that, which lead to ICEs earlier
for invalid code.

Add a generic helper that checks this and call it where needed
in the C frontend.

I chose to allow spawn/array for for init and increment expressions.
While the Cilk spec could be interpreted to forbid it there too
there didn't seem any reason to not allow it.

One dark corner is spawn, array in statement expressions not at
the end. Right now that's forbidden too.

gcc/c-family/:

2014-09-30  Andi Kleen  <ak@linux.intel.com>

	PR c/60804
	* c-common.h (check_no_cilk): Declare.
	* cilk.c (get_error_location): New function.
	(check_no_cilk): Dito.

gcc/c/:

2014-09-30  Andi Kleen  <ak@linux.intel.com>

	PR c/60804
	* c-parser.c (c_parser_statement_after_labels): Call
	check_no_cilk.
	(c_parser_if_statement): Dito.
	(c_parser_switch_statement): Dito.
	(c_parser_while_statement): Dito.
	(c_parser_do_statement): Dito.
	(c_parser_for_statement): Dito.
	* c-typeck.c (c_finish_loop): Dito.
---
 gcc/c-family/c-common.h |  1 +
 gcc/c-family/cilk.c     | 37 +++++++++++++++++++++++++++++++++
 gcc/c/c-parser.c        | 54 ++++++++++++++++++++++++-------------------------
 gcc/c/c-typeck.c        |  8 ++------
 4 files changed, 66 insertions(+), 34 deletions(-)

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 1e3477f..37ee156 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1395,4 +1395,5 @@ extern tree cilk_install_body_pedigree_operations (tree);
 extern void cilk_outline (tree, tree *, void *);
 extern bool contains_cilk_spawn_stmt (tree);
 extern tree cilk_for_number_of_iterations (tree);
+extern bool check_no_cilk (tree, const char *, location_t loc = UNKNOWN_LOCATION);
 #endif /* ! GCC_C_COMMON_H */
diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index 5b6684a..e33ef2b 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -1312,3 +1312,40 @@ contains_cilk_spawn_stmt (tree expr)
   return walk_tree (&expr, contains_cilk_spawn_stmt_walker, NULL, NULL)
 	 != NULL_TREE;
 }
+
+/* Return a error location for EXPR if LOC is not set.  */
+
+static location_t
+get_error_location (tree expr, location_t loc)
+{
+  if (loc == UNKNOWN_LOCATION)
+    {
+      if (TREE_CODE (expr) == MODIFY_EXPR)
+        expr = TREE_OPERAND (expr, 0);
+      loc = EXPR_LOCATION (expr);
+    }
+  return loc;
+}
+
+/* Check that no array notation or spawn statement is in EXPR.
+   If not true gemerate an error at LOC for WHAT.  */
+
+bool
+check_no_cilk (tree expr, const char *what, location_t loc)
+{
+  if (!flag_cilkplus)
+    return false;
+  if (contains_array_notation_expr (expr))
+    {
+      loc = get_error_location (expr, loc);
+      error_at (loc, "Cilk array notation cannot be used %s", what);
+      return true;
+    }
+  if (walk_tree (&expr, contains_cilk_spawn_stmt_walker, NULL, NULL))
+    {
+      loc = get_error_location (expr, loc);
+      error_at (loc, "%<_Cilk_spawn%> statement cannot be used %s", what);
+      return true;
+    }
+  return false;
+}
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 0d159fd..aa5a6cd 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -4926,6 +4926,8 @@ c_parser_statement_after_labels (c_parser *parser)
 
 	      c_parser_consume_token (parser);
 	      val = c_parser_expression (parser);
+	      if (check_no_cilk (val.value, "as a computed goto expression", loc))
+	        val.value = error_mark_node;
 	      val = convert_lvalue_to_rvalue (loc, val, false, true);
 	      stmt = c_finish_goto_ptr (loc, val.value);
 	    }
@@ -4979,8 +4981,13 @@ c_parser_statement_after_labels (c_parser *parser)
 	    {
 	      struct c_expr expr = c_parser_expression (parser);
 	      expr = convert_lvalue_to_rvalue (loc, expr, false, false);
-	      expr.value = c_fully_fold (expr.value, false, NULL);
-	      stmt = objc_build_throw_stmt (loc, expr.value);
+	      if (check_no_cilk (expr.value, "for a throw expression"))
+	        expr.value = error_mark_node;
+	      else
+		{
+	          expr.value = c_fully_fold (expr.value, false, NULL);
+	          stmt = objc_build_throw_stmt (loc, expr.value);
+		}
 	      goto expect_semicolon;
 	    }
 	  break;
@@ -5163,6 +5170,11 @@ c_parser_if_statement (c_parser *parser)
   block = c_begin_compound_stmt (flag_isoc99);
   loc = c_parser_peek_token (parser)->location;
   cond = c_parser_paren_condition (parser);
+  if (flag_cilkplus && contains_cilk_spawn_stmt (cond))
+    {
+      error_at (loc, "if statement cannot contain %<Cilk_spawn%>");
+      cond = error_mark_node;
+    }
   in_if_block = parser->in_if_block;
   parser->in_if_block = true;
   first_body = c_parser_if_body (parser, &first_if);
@@ -5209,13 +5221,10 @@ c_parser_switch_statement (c_parser *parser)
       ce = c_parser_expression (parser);
       ce = convert_lvalue_to_rvalue (switch_cond_loc, ce, true, false);
       expr = ce.value;
-      if (flag_cilkplus && contains_array_notation_expr (expr))
-	{
-	  error_at (switch_cond_loc,
-		    "array notations cannot be used as a condition for switch "
-		    "statement");
-	  expr = error_mark_node;
-	}
+      /* ??? expr has no valid location?  */
+      if (check_no_cilk (expr, "as a condition for switch statement",
+			 switch_cond_loc))
+        expr = error_mark_node;
       c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, "expected %<)%>");
     }
   else
@@ -5255,13 +5264,8 @@ c_parser_while_statement (c_parser *parser, bool ivdep)
   block = c_begin_compound_stmt (flag_isoc99);
   loc = c_parser_peek_token (parser)->location;
   cond = c_parser_paren_condition (parser);
-  if (flag_cilkplus && contains_array_notation_expr (cond))
-    {
-      error_at (loc, "array notations cannot be used as a condition for while "
-		"statement");
-      cond = error_mark_node;
-    }
-
+  if (check_no_cilk (cond, "as a condition for while statement"))
+    cond = error_mark_node;
   if (ivdep && cond != error_mark_node)
     cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
 		   build_int_cst (integer_type_node,
@@ -5307,12 +5311,8 @@ c_parser_do_statement (c_parser *parser, bool ivdep)
   new_cont = c_cont_label;
   c_cont_label = save_cont;
   cond = c_parser_paren_condition (parser);
-  if (flag_cilkplus && contains_array_notation_expr (cond))
-    {
-      error_at (loc, "array notations cannot be used as a condition for a "
-		"do-while statement");
-      cond = error_mark_node;
-    }
+  if (check_no_cilk (cond, "as a condition for a do-while statement"))
+    cond = error_mark_node;
   if (ivdep && cond != error_mark_node)
     cond = build2 (ANNOTATE_EXPR, TREE_TYPE (cond), cond,
 		   build_int_cst (integer_type_node,
@@ -5464,6 +5464,8 @@ c_parser_for_statement (c_parser *parser, bool ivdep)
 	    struct c_expr ce;
 	    tree init_expression;
 	    ce = c_parser_expression (parser);
+	    /* In theory we could forbid _Cilk_spawn here, as the spec says "only in top
+	       level statement", but it works just fine, so allow it.  */
 	    init_expression = ce.value;
 	    parser->objc_could_be_foreach_context = false;
 	    if (c_parser_next_token_is_keyword (parser, RID_IN))
@@ -5505,12 +5507,8 @@ c_parser_for_statement (c_parser *parser, bool ivdep)
 	  else
 	    {
 	      cond = c_parser_condition (parser);
-	      if (flag_cilkplus && contains_array_notation_expr (cond))
-		{
-		  error_at (loc, "array notations cannot be used in a "
-			    "condition for a for-loop");
-		  cond = error_mark_node;
-		}
+	      if (check_no_cilk (cond, "in a condition for a for-loop"))
+		cond = error_mark_node;
 	      c_parser_skip_until_found (parser, CPP_SEMICOLON,
 					 "expected %<;%>");
 	    }
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index f69c28b..9df1b94 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -9600,12 +9600,8 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
 {
   tree entry = NULL, exit = NULL, t;
 
-  if (flag_cilkplus && contains_array_notation_expr (cond))
-    {
-      error_at (start_locus, "array notation expression cannot be used in a "
-		"loop%'s condition");
-      return;
-    }
+  /* In theory could forbid cilk spawn for loop increment expression,
+     but it should work just fine.  */
   
   /* If the condition is zero don't generate a loop construct.  */
   if (cond && integer_zerop (cond))
-- 
2.1.1

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

* [PATCH 5/5] Add illegal cilk checks to C++ front.
  2014-10-02  4:28     ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Andi Kleen
@ 2014-10-02  4:28       ` Andi Kleen
  2014-10-27  6:37         ` [C++ PING] " Andi Kleen
  2014-11-10  5:04         ` Jason Merrill
  2014-10-02 18:01       ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Jeff Law
  1 sibling, 2 replies; 15+ messages in thread
From: Andi Kleen @ 2014-10-02  4:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Add calls for several illegal Cilk cases to the C++ frontend.
C++ usually doesn't ICE unlike C on illegal cilk, but it's
better to match C in what is allowed and what is not.

if (_Cilk_spawn ...) is still not errored, but at least it doesn't ICE.

gcc/cp/:

2014-09-30  Andi Kleen  <ak@linux.intel.com>

	* semantics.c (finish_goto_stmt): Call check_no_cilk.
	(finish_while_stmt_cond): Dito.
	(finish_do_stmt): Dito.
	(finish_for_cond): Dito.
	(finish_switch_cond): Dito.
---
 gcc/cp/semantics.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7569826..9ca03be 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -621,6 +621,8 @@ finish_goto_stmt (tree destination)
     TREE_USED (destination) = 1;
   else
     {
+      if (check_no_cilk (destination, "as a computed goto expression"))
+	destination = error_mark_node;
       destination = mark_rvalue_use (destination);
       if (!processing_template_decl)
 	{
@@ -792,6 +794,8 @@ begin_while_stmt (void)
 void
 finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep)
 {
+  if (check_no_cilk (cond, "as a condition for while statement"))
+    cond = error_mark_node;
   cond = maybe_convert_cond (cond);
   finish_cond (&WHILE_COND (while_stmt), cond);
   begin_maybe_infinite_loop (cond);
@@ -847,6 +851,8 @@ finish_do_body (tree do_stmt)
 void
 finish_do_stmt (tree cond, tree do_stmt, bool ivdep)
 {
+  if (check_no_cilk (cond, "as a condition for a do-while statement"))
+    cond = error_mark_node;
   cond = maybe_convert_cond (cond);
   end_maybe_infinite_loop (cond);
   if (ivdep && cond != error_mark_node)
@@ -956,6 +962,8 @@ finish_for_init_stmt (tree for_stmt)
 void
 finish_for_cond (tree cond, tree for_stmt, bool ivdep)
 {
+  if (check_no_cilk (cond, "in a condition for a for-loop"))
+    cond = error_mark_node;
   cond = maybe_convert_cond (cond);
   finish_cond (&FOR_COND (for_stmt), cond);
   begin_maybe_infinite_loop (cond);
@@ -1118,6 +1126,10 @@ void
 finish_switch_cond (tree cond, tree switch_stmt)
 {
   tree orig_type = NULL;
+
+  if (check_no_cilk (cond, "as a condition for switch statement"))
+    cond = error_mark_node;
+
   if (!processing_template_decl)
     {
       /* Convert the condition to an integer or enumeration type.  */
-- 
2.1.1

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

* [PATCH 1/5] Fix error location for cilk error message
@ 2014-10-02  4:28 Andi Kleen
  2014-10-02  4:28 ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Andi Kleen
  2014-10-02 18:00 ` [PATCH 1/5] Fix error location for cilk error message Jeff Law
  0 siblings, 2 replies; 15+ messages in thread
From: Andi Kleen @ 2014-10-02  4:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Output the correct location for an existing cilk error message.

gcc/c-family/:

2014-09-28  Andi Kleen  <ak@linux.intel.com>

	* cilk.c (recognize_spawn): Use expression location
	for error message.
---
 gcc/c-family/cilk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index 20b3432..5b6684a 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -235,7 +235,7 @@ recognize_spawn (tree exp, tree *exp0)
     }
   /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR.  */
   else if (contains_cilk_spawn_stmt (exp))
-    error ("invalid use of %<_Cilk_spawn%>");
+    error_at (EXPR_LOCATION (exp), "invalid use of %<_Cilk_spawn%>");
   return spawn_found;
 }
 
-- 
2.1.1

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

* [PATCH 4/5] Fix some of the existing Cilk tests for the new errors.
  2014-10-02  4:28   ` [PATCH 3/5] Add test cases for all the new cilk errors Andi Kleen
@ 2014-10-02  4:28     ` Andi Kleen
  2014-10-02  4:28       ` [PATCH 5/5] Add illegal cilk checks to C++ front Andi Kleen
  2014-10-02 18:01       ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Jeff Law
  2014-10-02 18:01     ` [PATCH 3/5] Add test cases for all the new cilk errors Jeff Law
  1 sibling, 2 replies; 15+ messages in thread
From: Andi Kleen @ 2014-10-02  4:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

gcc/testsuite/:

2014-09-30  Andi Kleen  <ak@linux.intel.com>

	* c-c++-common/cilk-plus/AN/misc.c (main): Handle
	new cilk errors.
---
 gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c
index 814786b..dcc414f 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/misc.c
@@ -73,13 +73,13 @@ int main (void)
   while (ii != array2[1:x:3][1:2:1]) /* { dg-error "cannot be used as a condition for while statement"  } */
     x = 2;
 
-  do { /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c } } */
+  do {
     x = 3;
-  } while (ii != array2[:][:]); /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c++ } } */
+  } while (ii != array2[:][:]); /* { dg-error "cannot be used as a condition for a do-while statement" } */
 
-  do {  /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c } } */
+  do {
     x = 2;
-  } while (ii != (x + array2[:][1:x:2]) + 2); /* { dg-error "cannot be used as a condition for a do-while statement" "" { target c++ } } */
+  } while (ii != (x + array2[:][1:x:2]) + 2); /* { dg-error "cannot be used as a condition for a do-while statement" } */
   
   do { 
     x += 3;
-- 
2.1.1

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

* Re: [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places
  2014-10-02  4:28 ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Andi Kleen
  2014-10-02  4:28   ` [PATCH 3/5] Add test cases for all the new cilk errors Andi Kleen
@ 2014-10-02 15:07   ` Joseph S. Myers
  1 sibling, 0 replies; 15+ messages in thread
From: Joseph S. Myers @ 2014-10-02 15:07 UTC (permalink / raw)
  To: Andi Kleen; +Cc: gcc-patches, Andi Kleen

On Wed, 1 Oct 2014, Andi Kleen wrote:

> +/* Check that no array notation or spawn statement is in EXPR.
> +   If not true gemerate an error at LOC for WHAT.  */
> +
> +bool
> +check_no_cilk (tree expr, const char *what, location_t loc)
> +{
> +  if (!flag_cilkplus)
> +    return false;
> +  if (contains_array_notation_expr (expr))
> +    {
> +      loc = get_error_location (expr, loc);
> +      error_at (loc, "Cilk array notation cannot be used %s", what);
> +      return true;
> +    }
> +  if (walk_tree (&expr, contains_cilk_spawn_stmt_walker, NULL, NULL))
> +    {
> +      loc = get_error_location (expr, loc);
> +      error_at (loc, "%<_Cilk_spawn%> statement cannot be used %s", what);

You need to pass two complete error messages to this function for i18n 
purposes, rather than building up messages from sentence fragments.  If 
you call them e.g. array_gmsgid and spawn_gmsgid they should both get 
extracted by exgettext for translation.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 1/5] Fix error location for cilk error message
  2014-10-02  4:28 [PATCH 1/5] Fix error location for cilk error message Andi Kleen
  2014-10-02  4:28 ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Andi Kleen
@ 2014-10-02 18:00 ` Jeff Law
  1 sibling, 0 replies; 15+ messages in thread
From: Jeff Law @ 2014-10-02 18:00 UTC (permalink / raw)
  To: Andi Kleen, gcc-patches; +Cc: Andi Kleen

On 10/01/14 22:26, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> Output the correct location for an existing cilk error message.
>
> gcc/c-family/:
>
> 2014-09-28  Andi Kleen  <ak@linux.intel.com>
>
> 	* cilk.c (recognize_spawn): Use expression location
> 	for error message.'
OK.
Jeff

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

* Re: [PATCH 4/5] Fix some of the existing Cilk tests for the new errors.
  2014-10-02  4:28     ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Andi Kleen
  2014-10-02  4:28       ` [PATCH 5/5] Add illegal cilk checks to C++ front Andi Kleen
@ 2014-10-02 18:01       ` Jeff Law
  1 sibling, 0 replies; 15+ messages in thread
From: Jeff Law @ 2014-10-02 18:01 UTC (permalink / raw)
  To: Andi Kleen, gcc-patches; +Cc: Andi Kleen

On 10/01/14 22:26, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> gcc/testsuite/:
>
> 2014-09-30  Andi Kleen  <ak@linux.intel.com>
>
> 	* c-c++-common/cilk-plus/AN/misc.c (main): Handle
> 	new cilk errors.
OK.
Jeff

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

* Re: [PATCH 3/5] Add test cases for all the new cilk errors
  2014-10-02  4:28   ` [PATCH 3/5] Add test cases for all the new cilk errors Andi Kleen
  2014-10-02  4:28     ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Andi Kleen
@ 2014-10-02 18:01     ` Jeff Law
  1 sibling, 0 replies; 15+ messages in thread
From: Jeff Law @ 2014-10-02 18:01 UTC (permalink / raw)
  To: Andi Kleen, gcc-patches; +Cc: Andi Kleen

On 10/01/14 22:26, Andi Kleen wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> gcc/testsuite/:
>
> 2014-09-30  Andi Kleen  <ak@linux.intel.com>
>
> 	* c-c++-common/cilk-plus/CK/errors.c: New test.
OK.
Jeff

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

* [C++ PING] Re: [PATCH 5/5] Add illegal cilk checks to C++ front.
  2014-10-02  4:28       ` [PATCH 5/5] Add illegal cilk checks to C++ front Andi Kleen
@ 2014-10-27  6:37         ` Andi Kleen
  2014-11-03 15:08           ` [C++ PING^2] " Andi Kleen
  2014-11-10  5:04         ` Jason Merrill
  1 sibling, 1 reply; 15+ messages in thread
From: Andi Kleen @ 2014-10-27  6:37 UTC (permalink / raw)
  To: gcc-patches

Andi Kleen <andi@firstfloor.org> writes:

Ping!

Can someone from the C++ side please approve this patch?
That's the only patch not approved in this patch kit, but blocking
the commit.

-Andi

> From: Andi Kleen <ak@linux.intel.com>
>
> Add calls for several illegal Cilk cases to the C++ frontend.
> C++ usually doesn't ICE unlike C on illegal cilk, but it's
> better to match C in what is allowed and what is not.
>
> if (_Cilk_spawn ...) is still not errored, but at least it doesn't ICE.
>
> gcc/cp/:
>
> 2014-09-30  Andi Kleen  <ak@linux.intel.com>
>
> 	* semantics.c (finish_goto_stmt): Call check_no_cilk.
> 	(finish_while_stmt_cond): Dito.
> 	(finish_do_stmt): Dito.
> 	(finish_for_cond): Dito.
> 	(finish_switch_cond): Dito.
> ---
>  gcc/cp/semantics.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
> index 7569826..9ca03be 100644
> --- a/gcc/cp/semantics.c
> +++ b/gcc/cp/semantics.c
> @@ -621,6 +621,8 @@ finish_goto_stmt (tree destination)
>      TREE_USED (destination) = 1;
>    else
>      {
> +      if (check_no_cilk (destination, "as a computed goto expression"))
> +	destination = error_mark_node;
>        destination = mark_rvalue_use (destination);
>        if (!processing_template_decl)
>  	{
> @@ -792,6 +794,8 @@ begin_while_stmt (void)
>  void
>  finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep)
>  {
> +  if (check_no_cilk (cond, "as a condition for while statement"))
> +    cond = error_mark_node;
>    cond = maybe_convert_cond (cond);
>    finish_cond (&WHILE_COND (while_stmt), cond);
>    begin_maybe_infinite_loop (cond);
> @@ -847,6 +851,8 @@ finish_do_body (tree do_stmt)
>  void
>  finish_do_stmt (tree cond, tree do_stmt, bool ivdep)
>  {
> +  if (check_no_cilk (cond, "as a condition for a do-while statement"))
> +    cond = error_mark_node;
>    cond = maybe_convert_cond (cond);
>    end_maybe_infinite_loop (cond);
>    if (ivdep && cond != error_mark_node)
> @@ -956,6 +962,8 @@ finish_for_init_stmt (tree for_stmt)
>  void
>  finish_for_cond (tree cond, tree for_stmt, bool ivdep)
>  {
> +  if (check_no_cilk (cond, "in a condition for a for-loop"))
> +    cond = error_mark_node;
>    cond = maybe_convert_cond (cond);
>    finish_cond (&FOR_COND (for_stmt), cond);
>    begin_maybe_infinite_loop (cond);
> @@ -1118,6 +1126,10 @@ void
>  finish_switch_cond (tree cond, tree switch_stmt)
>  {
>    tree orig_type = NULL;
> +
> +  if (check_no_cilk (cond, "as a condition for switch statement"))
> +    cond = error_mark_node;
> +
>    if (!processing_template_decl)
>      {
>        /* Convert the condition to an integer or enumeration type.  */

-- 
ak@linux.intel.com -- Speaking for myself only

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

* Re: [C++ PING^2] Re: [PATCH 5/5] Add illegal cilk checks to C++ front.
  2014-10-27  6:37         ` [C++ PING] " Andi Kleen
@ 2014-11-03 15:08           ` Andi Kleen
  2014-11-10 18:39             ` [C++ PING^3] " Andi Kleen
  0 siblings, 1 reply; 15+ messages in thread
From: Andi Kleen @ 2014-11-03 15:08 UTC (permalink / raw)
  To: gcc-patches

Andi Kleen <andi@firstfloor.org> writes:

Ping!^2

> Andi Kleen <andi@firstfloor.org> writes:
>
> Ping!
>
> Can someone from the C++ side please approve this patch?
> That's the only patch not approved in this patch kit, but blocking
> the commit.
>
> -Andi
>
>> From: Andi Kleen <ak@linux.intel.com>
>>
>> Add calls for several illegal Cilk cases to the C++ frontend.
>> C++ usually doesn't ICE unlike C on illegal cilk, but it's
>> better to match C in what is allowed and what is not.
>>
>> if (_Cilk_spawn ...) is still not errored, but at least it doesn't ICE.
>>
>> gcc/cp/:
>>
>> 2014-09-30  Andi Kleen  <ak@linux.intel.com>
>>
>> 	* semantics.c (finish_goto_stmt): Call check_no_cilk.
>> 	(finish_while_stmt_cond): Dito.
>> 	(finish_do_stmt): Dito.
>> 	(finish_for_cond): Dito.
>> 	(finish_switch_cond): Dito.
>> ---
>>  gcc/cp/semantics.c | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
>> index 7569826..9ca03be 100644
>> --- a/gcc/cp/semantics.c
>> +++ b/gcc/cp/semantics.c
>> @@ -621,6 +621,8 @@ finish_goto_stmt (tree destination)
>>      TREE_USED (destination) = 1;
>>    else
>>      {
>> +      if (check_no_cilk (destination, "as a computed goto expression"))
>> +	destination = error_mark_node;
>>        destination = mark_rvalue_use (destination);
>>        if (!processing_template_decl)
>>  	{
>> @@ -792,6 +794,8 @@ begin_while_stmt (void)
>>  void
>>  finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep)
>>  {
>> +  if (check_no_cilk (cond, "as a condition for while statement"))
>> +    cond = error_mark_node;
>>    cond = maybe_convert_cond (cond);
>>    finish_cond (&WHILE_COND (while_stmt), cond);
>>    begin_maybe_infinite_loop (cond);
>> @@ -847,6 +851,8 @@ finish_do_body (tree do_stmt)
>>  void
>>  finish_do_stmt (tree cond, tree do_stmt, bool ivdep)
>>  {
>> +  if (check_no_cilk (cond, "as a condition for a do-while statement"))
>> +    cond = error_mark_node;
>>    cond = maybe_convert_cond (cond);
>>    end_maybe_infinite_loop (cond);
>>    if (ivdep && cond != error_mark_node)
>> @@ -956,6 +962,8 @@ finish_for_init_stmt (tree for_stmt)
>>  void
>>  finish_for_cond (tree cond, tree for_stmt, bool ivdep)
>>  {
>> +  if (check_no_cilk (cond, "in a condition for a for-loop"))
>> +    cond = error_mark_node;
>>    cond = maybe_convert_cond (cond);
>>    finish_cond (&FOR_COND (for_stmt), cond);
>>    begin_maybe_infinite_loop (cond);
>> @@ -1118,6 +1126,10 @@ void
>>  finish_switch_cond (tree cond, tree switch_stmt)
>>  {
>>    tree orig_type = NULL;
>> +
>> +  if (check_no_cilk (cond, "as a condition for switch statement"))
>> +    cond = error_mark_node;
>> +
>>    if (!processing_template_decl)
>>      {
>>        /* Convert the condition to an integer or enumeration type.  */

-- 
ak@linux.intel.com -- Speaking for myself only

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

* Re: [PATCH 5/5] Add illegal cilk checks to C++ front.
  2014-10-02  4:28       ` [PATCH 5/5] Add illegal cilk checks to C++ front Andi Kleen
  2014-10-27  6:37         ` [C++ PING] " Andi Kleen
@ 2014-11-10  5:04         ` Jason Merrill
  2014-11-10  6:55           ` Jason Merrill
  2014-11-10 19:24           ` Andi Kleen
  1 sibling, 2 replies; 15+ messages in thread
From: Jason Merrill @ 2014-11-10  5:04 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

On 10/01/2014 11:26 PM, Andi Kleen wrote:
> +  if (check_no_cilk (cond, "in a condition for a for-loop"))

Why is this one "in" while the others are "as"?

The patch is OK in any case.

Please ping me directly on C++ patches.

Thanks,
Jason


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

* Re: [PATCH 5/5] Add illegal cilk checks to C++ front.
  2014-11-10  5:04         ` Jason Merrill
@ 2014-11-10  6:55           ` Jason Merrill
  2014-11-10 19:24           ` Andi Kleen
  1 sibling, 0 replies; 15+ messages in thread
From: Jason Merrill @ 2014-11-10  6:55 UTC (permalink / raw)
  To: Andi Kleen, gcc-patches; +Cc: Andi Kleen

On 10/01/2014 11:26 PM, Andi Kleen wrote:
> +  if (check_no_cilk (cond, "in a condition for a for-loop"))

Why is this one "in" while the others are "as"?

The patch is OK in any case.

Please ping me directly on C++ patches.

Thanks,
Jason

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

* Re: [C++ PING^3] Re: [PATCH 5/5] Add illegal cilk checks to C++ front.
  2014-11-03 15:08           ` [C++ PING^2] " Andi Kleen
@ 2014-11-10 18:39             ` Andi Kleen
  0 siblings, 0 replies; 15+ messages in thread
From: Andi Kleen @ 2014-11-10 18:39 UTC (permalink / raw)
  To: gcc-patches

Andi Kleen <andi@firstfloor.org> writes:

Ping!^3

> Andi Kleen <andi@firstfloor.org> writes:
>
> Ping!^2
>
>> Andi Kleen <andi@firstfloor.org> writes:
>>
>> Ping!
>>
>> Can someone from the C++ side please approve this patch?
>> That's the only patch not approved in this patch kit, but blocking
>> the commit.
>>
>> -Andi
>>
>>> From: Andi Kleen <ak@linux.intel.com>
>>>
>>> Add calls for several illegal Cilk cases to the C++ frontend.
>>> C++ usually doesn't ICE unlike C on illegal cilk, but it's
>>> better to match C in what is allowed and what is not.
>>>
>>> if (_Cilk_spawn ...) is still not errored, but at least it doesn't ICE.
>>>
>>> gcc/cp/:
>>>
>>> 2014-09-30  Andi Kleen  <ak@linux.intel.com>
>>>
>>> 	* semantics.c (finish_goto_stmt): Call check_no_cilk.
>>> 	(finish_while_stmt_cond): Dito.
>>> 	(finish_do_stmt): Dito.
>>> 	(finish_for_cond): Dito.
>>> 	(finish_switch_cond): Dito.
>>> ---
>>>  gcc/cp/semantics.c | 12 ++++++++++++
>>>  1 file changed, 12 insertions(+)
>>>
>>> diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
>>> index 7569826..9ca03be 100644
>>> --- a/gcc/cp/semantics.c
>>> +++ b/gcc/cp/semantics.c
>>> @@ -621,6 +621,8 @@ finish_goto_stmt (tree destination)
>>>      TREE_USED (destination) = 1;
>>>    else
>>>      {
>>> +      if (check_no_cilk (destination, "as a computed goto expression"))
>>> +	destination = error_mark_node;
>>>        destination = mark_rvalue_use (destination);
>>>        if (!processing_template_decl)
>>>  	{
>>> @@ -792,6 +794,8 @@ begin_while_stmt (void)
>>>  void
>>>  finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep)
>>>  {
>>> +  if (check_no_cilk (cond, "as a condition for while statement"))
>>> +    cond = error_mark_node;
>>>    cond = maybe_convert_cond (cond);
>>>    finish_cond (&WHILE_COND (while_stmt), cond);
>>>    begin_maybe_infinite_loop (cond);
>>> @@ -847,6 +851,8 @@ finish_do_body (tree do_stmt)
>>>  void
>>>  finish_do_stmt (tree cond, tree do_stmt, bool ivdep)
>>>  {
>>> +  if (check_no_cilk (cond, "as a condition for a do-while statement"))
>>> +    cond = error_mark_node;
>>>    cond = maybe_convert_cond (cond);
>>>    end_maybe_infinite_loop (cond);
>>>    if (ivdep && cond != error_mark_node)
>>> @@ -956,6 +962,8 @@ finish_for_init_stmt (tree for_stmt)
>>>  void
>>>  finish_for_cond (tree cond, tree for_stmt, bool ivdep)
>>>  {
>>> +  if (check_no_cilk (cond, "in a condition for a for-loop"))
>>> +    cond = error_mark_node;
>>>    cond = maybe_convert_cond (cond);
>>>    finish_cond (&FOR_COND (for_stmt), cond);
>>>    begin_maybe_infinite_loop (cond);
>>> @@ -1118,6 +1126,10 @@ void
>>>  finish_switch_cond (tree cond, tree switch_stmt)
>>>  {
>>>    tree orig_type = NULL;
>>> +
>>> +  if (check_no_cilk (cond, "as a condition for switch statement"))
>>> +    cond = error_mark_node;
>>> +
>>>    if (!processing_template_decl)
>>>      {
>>>        /* Convert the condition to an integer or enumeration type.  */

-- 
ak@linux.intel.com -- Speaking for myself only

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

* Re: [PATCH 5/5] Add illegal cilk checks to C++ front.
  2014-11-10  5:04         ` Jason Merrill
  2014-11-10  6:55           ` Jason Merrill
@ 2014-11-10 19:24           ` Andi Kleen
  1 sibling, 0 replies; 15+ messages in thread
From: Andi Kleen @ 2014-11-10 19:24 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Andi Kleen, gcc-patches, Andi Kleen

On Sun, Nov 09, 2014 at 11:03:50PM -0600, Jason Merrill wrote:
> On 10/01/2014 11:26 PM, Andi Kleen wrote:
> >+  if (check_no_cilk (cond, "in a condition for a for-loop"))
> 
> Why is this one "in" while the others are "as"?

I think "in" was somewhere hard coded in the test suite
and I wanted to minimize test suite changes. So I tried
to keep the existing messages the same as before.

> The patch is OK in any case.
> 
> Please ping me directly on C++ patches.

Ok.  Thanks.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

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

end of thread, other threads:[~2014-11-10 19:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-02  4:28 [PATCH 1/5] Fix error location for cilk error message Andi Kleen
2014-10-02  4:28 ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Andi Kleen
2014-10-02  4:28   ` [PATCH 3/5] Add test cases for all the new cilk errors Andi Kleen
2014-10-02  4:28     ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Andi Kleen
2014-10-02  4:28       ` [PATCH 5/5] Add illegal cilk checks to C++ front Andi Kleen
2014-10-27  6:37         ` [C++ PING] " Andi Kleen
2014-11-03 15:08           ` [C++ PING^2] " Andi Kleen
2014-11-10 18:39             ` [C++ PING^3] " Andi Kleen
2014-11-10  5:04         ` Jason Merrill
2014-11-10  6:55           ` Jason Merrill
2014-11-10 19:24           ` Andi Kleen
2014-10-02 18:01       ` [PATCH 4/5] Fix some of the existing Cilk tests for the new errors Jeff Law
2014-10-02 18:01     ` [PATCH 3/5] Add test cases for all the new cilk errors Jeff Law
2014-10-02 15:07   ` [PATCH 2/5] Error out for Cilk_spawn or array expression in forbidden places Joseph S. Myers
2014-10-02 18:00 ` [PATCH 1/5] Fix error location for cilk error message Jeff Law

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).