A small but major typo. The second sentence should read "...usage of _Cilk_spawn [ and _Cilk_sync] *without* -fcilkplus..." instead of "...with -fcilkplus..." I am sorry about this.
Sincerely, Balaji V. Iyer. > -----Original Message----- > From: Iyer, Balaji V > Sent: Tuesday, January 7, 2014 10:15 AM > To: gcc-patches@gcc.gnu.org > Subject: [PATCH] Fix PR 59631 > > Hello Everyone, > The attached patch will fix the issue reported in PR 59631. The main > issue was the usage of Cilk spawn [and _Cilk_sync] with -fcilkplus caused an > ICE. This patch should fix that. The issue was only reported for C++ but the > issue exists in C compiler also. This patch fixes both C and C++. A test > case is > also included. > > Is this Ok for trunk? > > Here are the ChangeLog entries: > +++ gcc/c/ChangeLog > +2014-01-07 Balaji V. Iyer <balaji.v.i...@intel.com> > + > + PR c++/59631 > + * c-parser.c (c_parser_postfix_expression): Replaced consecutive if > + statements with if-elseif statements. > > +++ gcc/testsuite/ChangeLog > +2014-01-07 Balaji V. Iyer <balaji.v.i...@intel.com> > + > + PR c++/59631 > + * gcc.dg/cilk-plus/cilk-plus.exp: Removed "-fcilkplus" from flags > list. > + * g++.dg/cilk-plus/cilk-plus.exp: Likewise. > + * c-c++-common/cilk-plus/CK/spawnee_inline.c: Replaced second dg- > option > + with dg-additional-options. > + * c-c++-common/cilk-plus/CK/varargs_test.c: Likewise. > + * c-c++-common/cilk-plus/CK/steal_check.c: Likewise. > + * c-c++-common/cilk-plus/CK/spawner_inline.c: Likewise. > + * c-c++-common/cilk-plus/CK/spawning_arg.c: Likewise. > + * c-c++-common/cilk-plus/CK/invalid_spawns.c: Added a dg-options > tag. > + * c-c++-common/cilk-plus/CK/pr59631.c: New testcase. > > +++ gcc/cp/ChangeLog > +2014-01-07 Balaji V. Iyer <balaji.v.i...@intel.com> > + > + PR c++/59631 > + * parser.c (cp_parser_postfix_expression): Added a new if-statement > + and replaced an existing if-statement with else-if statement. > + Changed an existing error message wording to match the one from the > C > + parser. > > Thanks, > > Balaji V. Iyer.
Index: gcc/c/c-parser.c =================================================================== --- gcc/c/c-parser.c (revision 206392) +++ gcc/c/c-parser.c (working copy) @@ -7500,7 +7500,7 @@ expr = c_parser_postfix_expression (parser); expr.value = error_mark_node; } - if (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN) + else if (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN) { error_at (loc, "consecutive %<_Cilk_spawn%> keywords " "are not permitted"); Index: gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp =================================================================== --- gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp (revision 206392) +++ gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp (working copy) @@ -51,13 +51,13 @@ dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -O3 -std=c99" " " dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]] " -fcilkplus -g -O0 -std=c99" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O1 -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -std=c99 -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -ftree-vectorize -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -g -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O1 " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -std=c99 " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -ftree-vectorize " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -g " " " if { [check_effective_target_lto] } { - dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -flto -g -fcilkplus" " " + dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -flto -g " " " } dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] " -g" " " Index: gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp =================================================================== --- gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp (revision 206392) +++ gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp (working copy) @@ -74,12 +74,12 @@ dg-finish dg-init -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O1 -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O2 -fcilkplus" " " -dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O3 -fcilkplus" " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O1 " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O2 " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -O3 " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O2 " " " +dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/CK/*.c]] " -g -O3 " " " dg-finish unset TEST_EXTRA_LIBS Index: gcc/testsuite/c-c++-common/cilk-plus/CK/spawnee_inline.c =================================================================== --- gcc/testsuite/c-c++-common/cilk-plus/CK/spawnee_inline.c (revision 206392) +++ gcc/testsuite/c-c++-common/cilk-plus/CK/spawnee_inline.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ /* { dg-options "-fcilkplus -w" } */ -/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ #include <stdio.h> #include <stdlib.h> Index: gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c =================================================================== --- gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c (revision 206392) +++ gcc/testsuite/c-c++-common/cilk-plus/CK/varargs_test.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ /* { dg-options "-fcilkplus" } */ -/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ #include <stdarg.h> #include <stdlib.h> Index: gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c =================================================================== --- gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c (revision 206392) +++ gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ /* { dg-options "-fcilkplus" } */ -/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ // #include <cilk/cilk_api.h> extern void __cilkrts_set_param (char *, char *); Index: gcc/testsuite/c-c++-common/cilk-plus/CK/spawner_inline.c =================================================================== --- gcc/testsuite/c-c++-common/cilk-plus/CK/spawner_inline.c (revision 206392) +++ gcc/testsuite/c-c++-common/cilk-plus/CK/spawner_inline.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ /* { dg-options "-fcilkplus" } */ -/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ #include <stdlib.h> #define DEFAULT_VALUE 30 Index: gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c =================================================================== --- gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c (revision 206392) +++ gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c (working copy) @@ -1,6 +1,6 @@ /* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ /* { dg-options "-fcilkplus" } */ -/* { dg-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ void f0(volatile int *steal_flag) { Index: gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_spawns.c =================================================================== --- gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_spawns.c (revision 206392) +++ gcc/testsuite/c-c++-common/cilk-plus/CK/invalid_spawns.c (working copy) @@ -1,3 +1,5 @@ +/* { dg-options "-fcilkplus" } */ + extern int foo (); int bar = _Cilk_spawn foo (); /* { dg-error "may only be used inside a function" } */ Index: gcc/testsuite/c-c++-common/cilk-plus/CK/pr59631.c =================================================================== --- gcc/testsuite/c-c++-common/cilk-plus/CK/pr59631.c (revision 0) +++ gcc/testsuite/c-c++-common/cilk-plus/CK/pr59631.c (revision 0) @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options " " } */ + +/* Tests the errors when Cilk keywords are used without -fcilkplus. */ + +void foo() +{ + _Cilk_spawn foo(); /* { dg-error "must be enabled to use" } */ +} + +void foo2 () +{ + _Cilk_spawn foo (); /* { dg-error "must be enabled to use" } */ + _Cilk_sync; /* { dg-error "must be enabled to use" } */ +} Index: gcc/cp/parser.c =================================================================== --- gcc/cp/parser.c (revision 206392) +++ gcc/cp/parser.c (working copy) @@ -5803,8 +5803,14 @@ postfix_expression = cp_parser_postfix_expression (parser, false, false, false, false, &idk); - if (saved_in_statement & IN_CILK_SPAWN) + if (!flag_enable_cilkplus) { + error_at (token->location, "-fcilkplus must be enabled to use" + " %<_Cilk_spawn%>"); + cfun->calls_cilk_spawn = 0; + } + else if (saved_in_statement & IN_CILK_SPAWN) + { error_at (token->location, "consecutive %<_Cilk_spawn%> keywords " "are not permitted"); postfix_expression = error_mark_node; @@ -5830,8 +5836,8 @@ finish_expr_stmt (sync_expr); } else - error_at (input_location, "_Cilk_sync cannot be used without enabling " - "Cilk Plus"); + error_at (token->location, "-fcilkplus must be enabled to use" + " %<_Cilk_sync%>"); cp_lexer_consume_token (parser->lexer); break;