diff mbox

[PR60189,Cilk+] Fix for ICE with incorrect Cilk_sync usage

Message ID 0EFAB2BDD0F67E4FB6CCC8B9F87D7569429FC4CC@IRSMSX103.ger.corp.intel.com
State New
Headers show

Commit Message

Zamyatin, Igor April 15, 2014, 3:01 p.m. UTC
> -----Original Message-----

> From: Jason Merrill [mailto:jason@redhat.com]

> Sent: Monday, April 14, 2014 9:49 PM

> To: Zamyatin, Igor; Jakub Jelinek

> Cc: GCC Patches (gcc-patches@gcc.gnu.org); Iyer, Balaji V

> Subject: Re: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect Cilk_sync usage

> 

> Oh, I see where the problem is coming from.  Cilk_sync is a statement, but

> it's being parsed as an expression.  Let's move it to cp_parser_statement.


Something like this (better to put new code in separate routine?)?


Thanks,
Igor

> 

> Jason

Comments

Zamyatin, Igor April 21, 2014, 7:26 p.m. UTC | #1
> > From: Jason Merrill [mailto:jason@redhat.com]

> > Sent: Monday, April 14, 2014 9:49 PM

> > To: Zamyatin, Igor; Jakub Jelinek

> > Cc: GCC Patches (gcc-patches@gcc.gnu.org); Iyer, Balaji V

> > Subject: Re: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect

> > Cilk_sync usage

> >

> > Oh, I see where the problem is coming from.  Cilk_sync is a statement,

> > but it's being parsed as an expression.  Let's move it to

> cp_parser_statement.

> 

> Something like this (better to put new code in separate routine?)?

> 

> diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bb59e3b..3105d6c 100644

> --- a/gcc/cp/parser.c

> +++ b/gcc/cp/parser.c

> @@ -5835,20 +5835,6 @@ cp_parser_postfix_expression (cp_parser

> *parser, bool address_p, bool cast_p,

>           }

>         break;

>        }

> -

> -    case RID_CILK_SYNC:

> -      if (flag_cilkplus)

> -       {

> -         tree sync_expr = build_cilk_sync ();

> -         SET_EXPR_LOCATION (sync_expr,

> -                            cp_lexer_peek_token (parser->lexer)->location);

> -         finish_expr_stmt (sync_expr);

> -       }

> -      else

> -       error_at (token->location, "-fcilkplus must be enabled to use"

> -                 " %<_Cilk_sync%>");

> -      cp_lexer_consume_token (parser->lexer);

> -      break;

> 

>      case RID_BUILTIN_SHUFFLE:

>        {

> @@ -9404,6 +9390,24 @@ cp_parser_statement (cp_parser* parser, tree

> in_statement_expr,

>           statement = cp_parser_jump_statement (parser);

>           break;

> 

> +       case RID_CILK_SYNC:

> +         cp_lexer_consume_token (parser->lexer);

> +         if (flag_cilkplus)

> +           {

> +             tree sync_expr = build_cilk_sync ();

> +             SET_EXPR_LOCATION (sync_expr,

> +                                token->location);

> +             statement = finish_expr_stmt (sync_expr);

> +           }

> +         else

> +           {

> +             error_at (token->location, "-fcilkplus must be enabled to use"

> +                       " %<_Cilk_sync%>");

> +             statement = error_mark_node;

> +           }

> +         cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);

> +         break;

> +

>           /* Objective-C++ exception-handling constructs.  */

>         case RID_AT_TRY:

>         case RID_AT_CATCH:

> 

> Thanks,

> Igor

> 


Jason,

Does the above change make sense?


Thanks in advance,
Igor

> >

> > Jason
Zamyatin, Igor May 12, 2014, 8:27 p.m. UTC | #2
Ping. Should I prepare the patch?

Thanks,
Igor
 
> > -----Original Message----

> > From: Jason Merrill [mailto:jason@redhat.com]

> > Sent: Monday, April 14, 2014 9:49 PM

> > To: Zamyatin, Igor; Jakub Jelinek

> > Cc: GCC Patches (gcc-patches@gcc.gnu.org); Iyer, Balaji V

> > Subject: Re: [PATCH, PR60189, Cilk+] Fix for ICE with incorrect

> > Cilk_sync usage

> >

> > Oh, I see where the problem is coming from.  Cilk_sync is a statement,

> > but it's being parsed as an expression.  Let's move it to

> cp_parser_statement.

> 

> Something like this (better to put new code in separate routine?)?

> 

> diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index bb59e3b..3105d6c 100644

> --- a/gcc/cp/parser.c

> +++ b/gcc/cp/parser.c

> @@ -5835,20 +5835,6 @@ cp_parser_postfix_expression (cp_parser

> *parser, bool address_p, bool cast_p,

>           }

>         break;

>        }

> -

> -    case RID_CILK_SYNC:

> -      if (flag_cilkplus)

> -       {

> -         tree sync_expr = build_cilk_sync ();

> -         SET_EXPR_LOCATION (sync_expr,

> -                            cp_lexer_peek_token (parser->lexer)->location);

> -         finish_expr_stmt (sync_expr);

> -       }

> -      else

> -       error_at (token->location, "-fcilkplus must be enabled to use"

> -                 " %<_Cilk_sync%>");

> -      cp_lexer_consume_token (parser->lexer);

> -      break;

> 

>      case RID_BUILTIN_SHUFFLE:

>        {

> @@ -9404,6 +9390,24 @@ cp_parser_statement (cp_parser* parser, tree

> in_statement_expr,

>           statement = cp_parser_jump_statement (parser);

>           break;

> 

> +       case RID_CILK_SYNC:

> +         cp_lexer_consume_token (parser->lexer);

> +         if (flag_cilkplus)

> +           {

> +             tree sync_expr = build_cilk_sync ();

> +             SET_EXPR_LOCATION (sync_expr,

> +                                token->location);

> +             statement = finish_expr_stmt (sync_expr);

> +           }

> +         else

> +           {

> +             error_at (token->location, "-fcilkplus must be enabled to use"

> +                       " %<_Cilk_sync%>");

> +             statement = error_mark_node;

> +           }

> +         cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);

> +         break;

> +

>           /* Objective-C++ exception-handling constructs.  */

>         case RID_AT_TRY:

>         case RID_AT_CATCH:

> 

> Thanks,

> Igor

> 

> >

> > Jason
diff mbox

Patch

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index bb59e3b..3105d6c 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -5835,20 +5835,6 @@  cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
          }
        break;
       }
-      
-    case RID_CILK_SYNC:
-      if (flag_cilkplus)
-       { 
-         tree sync_expr = build_cilk_sync ();
-         SET_EXPR_LOCATION (sync_expr, 
-                            cp_lexer_peek_token (parser->lexer)->location);
-         finish_expr_stmt (sync_expr);
-       }
-      else
-       error_at (token->location, "-fcilkplus must be enabled to use" 
-                 " %<_Cilk_sync%>");
-      cp_lexer_consume_token (parser->lexer);
-      break;
 
     case RID_BUILTIN_SHUFFLE:
       {
@@ -9404,6 +9390,24 @@  cp_parser_statement (cp_parser* parser, tree in_statement_expr,
          statement = cp_parser_jump_statement (parser);
          break;
 
+       case RID_CILK_SYNC:
+         cp_lexer_consume_token (parser->lexer);
+         if (flag_cilkplus)
+           {
+             tree sync_expr = build_cilk_sync ();
+             SET_EXPR_LOCATION (sync_expr,
+                                token->location);
+             statement = finish_expr_stmt (sync_expr);
+           }
+         else
+           {
+             error_at (token->location, "-fcilkplus must be enabled to use"
+                       " %<_Cilk_sync%>");
+             statement = error_mark_node;
+           }
+         cp_parser_require (parser, CPP_SEMICOLON, RT_SEMICOLON);
+         break;
+
          /* Objective-C++ exception-handling constructs.  */
        case RID_AT_TRY:
        case RID_AT_CATCH: