diff mbox

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

Message ID 1412224018-25368-5-git-send-email-andi@firstfloor.org
State New
Headers show

Commit Message

Andi Kleen Oct. 2, 2014, 4:26 a.m. UTC
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(+)

Comments

Andi Kleen Oct. 27, 2014, 5:50 a.m. UTC | #1
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.  */
Andi Kleen Nov. 3, 2014, 3:06 p.m. UTC | #2
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.  */
Jason Merrill Nov. 10, 2014, 5:03 a.m. UTC | #3
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
Andi Kleen Nov. 10, 2014, 6:39 p.m. UTC | #4
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.  */
Andi Kleen Nov. 10, 2014, 7:19 p.m. UTC | #5
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
diff mbox

Patch

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.  */