This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Improve diagnostic messages of "#pragma omp cancel", "#pragma omp cancellation point" parsing (was: Clarify PRAGMA_OACC_* and PRAGMA_OMP_*)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Thomas Schwinge <thomas at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Jun 2016 14:25:28 +0200
- Subject: Re: Improve diagnostic messages of "#pragma omp cancel", "#pragma omp cancellation point" parsing (was: Clarify PRAGMA_OACC_* and PRAGMA_OMP_*)
- Authentication-results: sourceware.org; auth=none
- References: <8737nxpl3v dot fsf at hertz dot schwinge dot homeip dot net> <87wpl9o69q dot fsf at hertz dot schwinge dot homeip dot net>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Jun 28, 2016 at 02:19:13PM +0200, Thomas Schwinge wrote:
> This also makes it obvious that stuff like:
>
> void foo()
> {
> if (0)
> #pragma omp cancellation FOO
> ;
> }
>
> ... currently produces "wrong" ;-) diagnostics:
>
> ../omp.c: In function 'foo':
> ../omp.c:4:9: error: '#pragma omp cancellation point' may only be used in compound statements before '#pragma'
> #pragma omp cancellation FOO
> ^~~
>
> We have in fact not yet parsed "#pragma omp cancellation point". I
> corrected that. And the "before '#pragma'" also doesn't make sense in
> that diagnostic message, so I switched that to use error_at instead of
> c_parser_error/cp_parser_error (this remains to be fixed for other cases
> in c_parser_pragma). And, for one diagnostic, C++ used
> cp_parser_require_pragma_eol instead of cp_parser_skip_to_pragma_eol,
> resulting in spurious "error: expected end of line before [...]"
> diagnostics, also fixed. And, a few missing "%>" added. At that point,
> I stopped looking for additional things to fix. ;-)
>
> OK for trunk?
This LGTM if you tweak it to apply without the previous patch or with just
a patch for PRAGMA_OMP_DECLARE.
Thanks.
> commit 2e17681659f8f8ec1ce3419c6587e1ee569ee8bc
> Author: Thomas Schwinge <thomas@codesourcery.com>
> Date: Tue Jun 28 14:16:20 2016 +0200
>
> Improve diagnostic messages of "#pragma omp cancel", "#pragma omp cancellation point" parsing
>
> gcc/c/
> * c-parser.c (c_parser_pragma) <PRAGMA_OMP_CANCELLATION>: Move
> pragma context checking into...
> (c_parser_omp_cancellation_point): ... here, and improve
> diagnostic messages.
> * c-typeck.c (c_finish_omp_cancel)
> (c_finish_omp_cancellation_point): Improve diagnostic messages.
> gcc/cp/
> * parser.c (cp_parser_pragma) <PRAGMA_OMP_CANCELLATION>: Move
> pragma context checking into...
> (cp_parser_omp_cancellation_point): ... here, and improve
> diagnostic messages.
> * semantics.c (finish_omp_cancel, finish_omp_cancellation_point):
> Improve diagnostic messages.
> gcc/testsuite/
> * c-c++-common/gomp/cancel-1.c: Extend.
Jakub