Re: [PATCH 2/2] Add illegal cilk checks to C++ front.

2014-10-03 Thread Paolo Carlini

Hi,

On 10/03/2014 07:50 PM, Andi Kleen wrote:

I have no idea, but there are lots of error_at() all over while
don't use _.  So I just follow precedence.

The problem is, you are *not* calling error_at directly, you are

According to Joseph it's ok because I named the arguments _msgid.

Ok then, I didn't notice that. Sorry for the false alarm.

Paolo.


Re: [PATCH 2/2] Add illegal cilk checks to C++ front.

2014-10-03 Thread Andi Kleen
> >I have no idea, but there are lots of error_at() all over while
> >don't use _.  So I just follow precedence.
> The problem is, you are *not* calling error_at directly, you are

According to Joseph it's ok because I named the arguments _msgid.

-Andi


Re: [PATCH 2/2] Add illegal cilk checks to C++ front.

2014-10-03 Thread Paolo Carlini

Hi,

On 10/03/2014 07:13 PM, Andi Kleen wrote:

On Fri, Oct 03, 2014 at 07:10:05PM +0200, Paolo Carlini wrote:

Hi,

On 10/03/2014 04:08 PM, Andi Kleen wrote:

+  if (check_no_cilk (destination,
+"Cilk array notation cannot be used as a computed goto expression",
+"%<_Cilk_spawn%> statement cannot be used as a computed goto 
expression"))
+   destination = error_mark_node;

Are you sure this kind of error messages will be automatically
translated without helping the machinery by wrapping the string
literals in G_() ?

I have no idea, but there are lots of error_at() all over while
don't use _.  So I just follow precedence.
The problem is, you are *not* calling error_at directly, you are using 
check_no_cilk and passing pointers. In fact, I think you actually do 
need G_, as in many other places of the front-end. If unsure, double check:


https://gcc.gnu.org/translation.html

Paolo.


Re: [PATCH 2/2] Add illegal cilk checks to C++ front.

2014-10-03 Thread Andi Kleen
On Fri, Oct 03, 2014 at 07:10:05PM +0200, Paolo Carlini wrote:
> Hi,
> 
> On 10/03/2014 04:08 PM, Andi Kleen wrote:
> >+  if (check_no_cilk (destination,
> >+ "Cilk array notation cannot be used as a computed goto expression",
> >+ "%<_Cilk_spawn%> statement cannot be used as a computed goto 
> >expression"))
> >+destination = error_mark_node;
> Are you sure this kind of error messages will be automatically
> translated without helping the machinery by wrapping the string
> literals in G_() ?

I have no idea, but there are lots of error_at() all over while
don't use _.  So I just follow precedence.

-Andi


Re: [PATCH 2/2] Add illegal cilk checks to C++ front.

2014-10-03 Thread Paolo Carlini

Hi,

On 10/03/2014 04:08 PM, Andi Kleen wrote:

+  if (check_no_cilk (destination,
+"Cilk array notation cannot be used as a computed goto expression",
+"%<_Cilk_spawn%> statement cannot be used as a computed goto 
expression"))
+   destination = error_mark_node;
Are you sure this kind of error messages will be automatically 
translated without helping the machinery by wrapping the string literals 
in G_() ?


Paolo.


[PATCH 2/2] Add illegal cilk checks to C++ front.

2014-10-03 Thread Andi Kleen
From: Andi Kleen 

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  

* 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 | 22 ++
 1 file changed, 22 insertions(+)

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 7569826..e7ff223 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -621,6 +621,10 @@ finish_goto_stmt (tree destination)
 TREE_USED (destination) = 1;
   else
 {
+  if (check_no_cilk (destination,
+"Cilk array notation cannot be used as a computed goto expression",
+"%<_Cilk_spawn%> statement cannot be used as a computed goto 
expression"))
+   destination = error_mark_node;
   destination = mark_rvalue_use (destination);
   if (!processing_template_decl)
{
@@ -792,6 +796,10 @@ begin_while_stmt (void)
 void
 finish_while_stmt_cond (tree cond, tree while_stmt, bool ivdep)
 {
+  if (check_no_cilk (cond,
+  "Cilk array notation cannot be used as a condition for while statement",
+  "%<_Cilk_spawn%> statement cannot be used 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 +855,10 @@ finish_do_body (tree do_stmt)
 void
 finish_do_stmt (tree cond, tree do_stmt, bool ivdep)
 {
+  if (check_no_cilk (cond,
+  "Cilk array notation cannot be used as a condition for a do-while statement",
+  "%<_Cilk_spawn%> statement cannot be used 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 +968,10 @@ finish_for_init_stmt (tree for_stmt)
 void
 finish_for_cond (tree cond, tree for_stmt, bool ivdep)
 {
+  if (check_no_cilk (cond,
+"Cilk array notation cannot be used in a condition for a for-loop",
+"%<_Cilk_spawn%> statement cannot be used 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 +1134,12 @@ void
 finish_switch_cond (tree cond, tree switch_stmt)
 {
   tree orig_type = NULL;
+
+  if (check_no_cilk (cond,
+   "Cilk array notation cannot be used as a condition for switch 
statement",
+   "%<_Cilk_spawn%> statement cannot be used 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