From 41521dee8edc8fcfbc8fb2d56773d85f909bf356 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 23 Nov 2017 21:17:29 +0100 Subject: [PATCH] c-parser.c (c_parser_omp_declare_simd): Reject declare simd in pragma_stmt context. * c-parser.c (c_parser_omp_declare_simd): Reject declare simd in pragma_stmt context. * gcc.dg/gomp/declare-simd-1.c (f9): Remove. * gcc.dg/gomp/declare-simd-5.c: New test. From-SVN: r255116 --- gcc/c/ChangeLog | 5 ++++ gcc/c/c-parser.c | 2 +- gcc/testsuite/ChangeLog | 3 ++ gcc/testsuite/gcc.dg/gomp/declare-simd-1.c | 12 -------- gcc/testsuite/gcc.dg/gomp/declare-simd-5.c | 35 ++++++++++++++++++++++ 5 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/gomp/declare-simd-5.c diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 1d71829d919..1d698508131 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2017-11-23 Jakub Jelinek + + * c-parser.c (c_parser_omp_declare_simd): Reject declare simd in + pragma_stmt context. + 2017-11-23 Mike Stump Eric Botcazou diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 7eb0f562518..9a6685a6744 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -17486,11 +17486,11 @@ c_parser_omp_declare_simd (c_parser *parser, enum pragma_context context) break; case pragma_struct: case pragma_param: + case pragma_stmt: c_parser_error (parser, "%<#pragma omp declare simd%> must be followed by " "function declaration or definition"); break; case pragma_compound: - case pragma_stmt: if (c_parser_next_token_is (parser, CPP_KEYWORD) && c_parser_peek_token (parser)->keyword == RID_EXTENSION) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index de4941c3ae9..619e9593bb3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2017-11-23 Jakub Jelinek + * gcc.dg/gomp/declare-simd-1.c (f9): Remove. + * gcc.dg/gomp/declare-simd-5.c: New test. + * g++.dg/pr65240-1.C: Add -Wno-return-type to dg-options. * g++.dg/pr65240-2.C: Likewise. * g++.dg/pr65240-3.C: Likewise. diff --git a/gcc/testsuite/gcc.dg/gomp/declare-simd-1.c b/gcc/testsuite/gcc.dg/gomp/declare-simd-1.c index 5022fbbc057..b8bba1f892b 100644 --- a/gcc/testsuite/gcc.dg/gomp/declare-simd-1.c +++ b/gcc/testsuite/gcc.dg/gomp/declare-simd-1.c @@ -58,18 +58,6 @@ f7 (int x) /* { dg-final { scan-assembler-times "_ZGVeM16v_f7:" 1 { target { i?86-*-* x86_64-*-* } } } } */ /* { dg-final { scan-assembler-times "_ZGVeN16v_f7:" 1 { target { i?86-*-* x86_64-*-* } } } } */ -int -f9 (int x) -{ - if (x) - #pragma omp declare simd simdlen (8) aligned (b : 8 * sizeof (int)) - extern int f10 (int a, int *b, int c); - while (x < 10) - #pragma omp declare simd simdlen (8) aligned (b : 8 * sizeof (int)) - extern int f11 (int a, int *b, int c); - return x; -} - #pragma omp declare simd uniform (a) aligned (b : 8 * sizeof (int)) linear (c : 4) simdlen (8) int f12 (int c; int *b; int a; int a, int *b, int c); diff --git a/gcc/testsuite/gcc.dg/gomp/declare-simd-5.c b/gcc/testsuite/gcc.dg/gomp/declare-simd-5.c new file mode 100644 index 00000000000..fe236525d62 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/declare-simd-5.c @@ -0,0 +1,35 @@ +/* Test parsing of #pragma omp declare simd */ +/* { dg-do compile } */ + +int +f1 (int x) +{ + if (x) + #pragma omp declare simd simdlen (8) aligned (b : 8 * sizeof (int)) + extern int f3 (int a, int *b, int c); /* { dg-error "must be followed by function declaration or definition" } */ + while (x < 10) + #pragma omp declare simd simdlen (8) aligned (b : 8 * sizeof (int)) + extern int f4 (int a, int *b, int c); /* { dg-error "must be followed by function declaration or definition" } */ + { +lab: + #pragma omp declare simd simdlen (8) aligned (b : 8 * sizeof (int)) + extern int f5 (int a, int *b, int c); /* { dg-error "must be followed by function declaration or definition" } */ + x++; /* { dg-error "expected expression before" "" { target *-*-* } .-1 } */ + } + return x; +} + +int +f2 (int x) +{ + if (x) + extern int f6 (int a, int *b, int c); /* { dg-error "expected expression before" } */ + while (x < 10) + extern int f7 (int a, int *b, int c); /* { dg-error "expected expression before" } */ + { +lab: + extern int f8 (int a, int *b, int c); /* { dg-error "a label can only be part of a statement and a declaration is not a statement" } */ + x++; + } + return x; +} -- 2.30.2