diff options
author | Marek Polacek <polacek@redhat.com> | 2016-03-04 13:26:25 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-03-04 13:26:25 +0000 |
commit | 7ff6ca3899e0cae8460f7dc30770002559bc0553 (patch) | |
tree | 4ca9771c72769236beaba3b26955cd20839b2e53 | |
parent | a6bf62d5f85e91c7545bfc5cf2f8a5364814423b (diff) | |
download | gcc-7ff6ca3899e0cae8460f7dc30770002559bc0553.zip gcc-7ff6ca3899e0cae8460f7dc30770002559bc0553.tar.gz gcc-7ff6ca3899e0cae8460f7dc30770002559bc0553.tar.bz2 |
re PR c/69798 (ICE on invalid code on x86_64-linux-gnu in c_parser_braced_init, at c/c-parser.c:4338)
PR c/69798
* c-parser.c (c_parser_postfix_expression): Call
c_parser_cast_expression rather than c_parser_postfix_expression.
* gcc.dg/cilk-plus/pr69798-1.c: New test.
* gcc.dg/cilk-plus/pr69798-2.c: New test.
From-SVN: r233965
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cilk-plus/pr69798-1.c | 73 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cilk-plus/pr69798-2.c | 72 |
5 files changed, 162 insertions, 5 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 004d7c5..1fe4f82 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-03-04 Marek Polacek <polacek@redhat.com> + + PR c/69798 + * c-parser.c (c_parser_postfix_expression): Call + c_parser_cast_expression rather than c_parser_postfix_expression. + 2016-03-01 Jakub Jelinek <jakub@redhat.com> PR c/69796 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index bb508b7..a7d5827 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -8024,8 +8024,8 @@ c_parser_postfix_expression (c_parser *parser) { error_at (loc, "-fcilkplus must be enabled to use " "%<_Cilk_spawn%>"); - expr = c_parser_postfix_expression (parser); - expr.value = error_mark_node; + expr = c_parser_cast_expression (parser, NULL); + expr.value = error_mark_node; } else if (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN) { @@ -8034,14 +8034,14 @@ c_parser_postfix_expression (c_parser *parser) /* Now flush out all the _Cilk_spawns. */ while (c_parser_peek_token (parser)->keyword == RID_CILK_SPAWN) c_parser_consume_token (parser); - expr = c_parser_postfix_expression (parser); + expr = c_parser_cast_expression (parser, NULL); } else { - expr = c_parser_postfix_expression (parser); + expr = c_parser_cast_expression (parser, NULL); expr.value = build_cilk_spawn (loc, expr.value); } - break; + break; default: c_parser_error (parser, "expected expression"); expr.value = error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 76c10ed..7a05cd3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-03-04 Marek Polacek <polacek@redhat.com> + + PR c/69798 + * gcc.dg/cilk-plus/pr69798-1.c: New test. + * gcc.dg/cilk-plus/pr69798-2.c: New test. + 2016-03-04 Kyrylo Tkachov <kyrylo.tkachov@arm.com> PR target/70004 diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pr69798-1.c b/gcc/testsuite/gcc.dg/cilk-plus/pr69798-1.c new file mode 100644 index 0000000..c5a37a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/pr69798-1.c @@ -0,0 +1,73 @@ +/* PR c/69798 */ +/* { dg-do compile } */ +/* { dg-options "-fcilkplus" } */ + +extern int foo (void); + +void +fn1 (int i, int *p) +{ +l: + _Cilk_spawn (void); /* { dg-error "expected expression" } */ + _Cilk_spawn (char []); /* { dg-error "expected expression" } */ + _Cilk_spawn (int *); /* { dg-error "expected expression" } */ + _Cilk_spawn (int) 1; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ({}); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ++i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn i++; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn --i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn i--; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn &i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn +i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn -i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ~i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn !i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn *p; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn &&l; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn sizeof (i); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn sizeof (short); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __alignof__ (i); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __alignof__ (short); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __extension__ i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __func__; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn p[0]; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __real__ i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __imag__ i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn !foo (); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ~foo (); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn (unsigned) foo (); /* { dg-error "only function calls can be spawned" } */ +} + +void +fn2 (int i, int *p) +{ +l: + _Cilk_spawn _Cilk_spawn (void); /* { dg-error "consecutive|expected expression" } */ + _Cilk_spawn _Cilk_spawn (char []); /* { dg-error "consecutive|expected expression" } */ + _Cilk_spawn _Cilk_spawn (int *); /* { dg-error "consecutive|expected expression" } */ + _Cilk_spawn _Cilk_spawn (int) 1; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ({}); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ++i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn i++; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn --i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn i--; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn &i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn +i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn -i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ~i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn !i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn *p; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn &&l; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn sizeof (i); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn sizeof (short); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __alignof__ (i); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __alignof__ (short); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __extension__ i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __func__; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn p[0]; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __real__ i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __imag__ i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn !foo (); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ~foo (); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn (unsigned) foo (); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ +} diff --git a/gcc/testsuite/gcc.dg/cilk-plus/pr69798-2.c b/gcc/testsuite/gcc.dg/cilk-plus/pr69798-2.c new file mode 100644 index 0000000..6719225 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cilk-plus/pr69798-2.c @@ -0,0 +1,72 @@ +/* PR c/69798 */ +/* { dg-do compile } */ + +extern int foo (void); + +void +fn1 (int i, int *p) +{ +l: + _Cilk_spawn (void); /* { dg-error "expected expression" } */ + _Cilk_spawn (char []); /* { dg-error "expected expression" } */ + _Cilk_spawn (int *); /* { dg-error "expected expression" } */ + _Cilk_spawn (int) 1; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ({}); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ++i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn i++; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn --i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn i--; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn &i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn +i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn -i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ~i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn !i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn *p; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn &&l; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn sizeof (i); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn sizeof (short); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __alignof__ (i); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __alignof__ (short); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __extension__ i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __func__; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn p[0]; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __real__ i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn __imag__ i; /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn !foo (); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn ~foo (); /* { dg-error "only function calls can be spawned" } */ + _Cilk_spawn (unsigned) foo (); /* { dg-error "only function calls can be spawned" } */ +} + +void +fn2 (int i, int *p) +{ +l: + _Cilk_spawn _Cilk_spawn (void); /* { dg-error "consecutive|expected expression" } */ + _Cilk_spawn _Cilk_spawn (char []); /* { dg-error "consecutive|expected expression" } */ + _Cilk_spawn _Cilk_spawn (int *); /* { dg-error "consecutive|expected expression" } */ + _Cilk_spawn _Cilk_spawn (int) 1; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ({}); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ++i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn i++; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn --i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn i--; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn &i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn +i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn -i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ~i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn !i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn *p; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn &&l; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn sizeof (i); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn sizeof (short); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __alignof__ (i); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __alignof__ (short); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __extension__ i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __func__; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn p[0]; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __real__ i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn __imag__ i; /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn !foo (); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn ~foo (); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ + _Cilk_spawn _Cilk_spawn (unsigned) foo (); /* { dg-error "consecutive ._Cilk_spawn. keywords are not permitted" } */ +} |