diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2016-06-29 11:08:04 +0200 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gcc.gnu.org> | 2016-06-29 11:08:04 +0200 |
commit | 54d19c3b7fb38097973a57b6e822e15cbcbd031d (patch) | |
tree | 607bd431945a31016513565efdb3f36e5a571dfb /gcc/c | |
parent | f9d8d99478f3b02e55a69b166a70646c87a7f5cd (diff) | |
download | gcc-54d19c3b7fb38097973a57b6e822e15cbcbd031d.zip gcc-54d19c3b7fb38097973a57b6e822e15cbcbd031d.tar.gz gcc-54d19c3b7fb38097973a57b6e822e15cbcbd031d.tar.bz2 |
Improve diagnostic messages of "#pragma omp cancel", "#pragma omp cancellation point" parsing
gcc/c/
* c-parser.c (c_parser_pragma) <PRAGMA_OMP_CANCELLATION_POINT>:
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_POINT>:
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.
From-SVN: r237843
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 24 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 4 |
3 files changed, 25 insertions, 12 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index df73934..7bd112b 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,12 @@ +2016-06-29 Thomas Schwinge <thomas@codesourcery.com> + + * c-parser.c (c_parser_pragma) <PRAGMA_OMP_CANCELLATION_POINT>: + 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. + 2016-06-29 Jakub Jelinek <jakub@redhat.com> PR c/71685 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 1d2dac7..1a50dea 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -1358,11 +1358,11 @@ static tree c_parser_omp_for_loop (location_t, c_parser *, enum tree_code, static void c_parser_omp_taskwait (c_parser *); static void c_parser_omp_taskyield (c_parser *); static void c_parser_omp_cancel (c_parser *); -static void c_parser_omp_cancellation_point (c_parser *); enum pragma_context { pragma_external, pragma_struct, pragma_param, pragma_stmt, pragma_compound }; static bool c_parser_pragma (c_parser *, enum pragma_context, bool *); +static void c_parser_omp_cancellation_point (c_parser *, enum pragma_context); static bool c_parser_omp_target (c_parser *, enum pragma_context, bool *); static void c_parser_omp_end_declare_target (c_parser *); static void c_parser_omp_declare (c_parser *, enum pragma_context); @@ -10187,14 +10187,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) return false; case PRAGMA_OMP_CANCELLATION_POINT: - if (context != pragma_compound) - { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma omp cancellation point%> may " - "only be used in compound statements"); - goto bad_stmt; - } - c_parser_omp_cancellation_point (parser); + c_parser_omp_cancellation_point (parser, context); return false; case PRAGMA_OMP_THREADPRIVATE: @@ -15668,7 +15661,7 @@ c_parser_omp_cancel (c_parser *parser) | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_TASKGROUP)) static void -c_parser_omp_cancellation_point (c_parser *parser) +c_parser_omp_cancellation_point (c_parser *parser, enum pragma_context context) { location_t loc = c_parser_peek_token (parser)->location; tree clauses; @@ -15691,6 +15684,17 @@ c_parser_omp_cancellation_point (c_parser *parser) return; } + if (context != pragma_compound) + { + if (context == pragma_stmt) + error_at (loc, "%<#pragma omp cancellation point%> may only be used in" + " compound statements"); + else + c_parser_error (parser, "expected declaration specifiers"); + c_parser_skip_to_pragma_eol (parser, false); + return; + } + clauses = c_parser_omp_all_clauses (parser, OMP_CANCELLATION_POINT_CLAUSE_MASK, "#pragma omp cancellation point"); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 56268fc..b2435de 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -11933,7 +11933,7 @@ c_finish_omp_cancel (location_t loc, tree clauses) mask = 8; else { - error_at (loc, "%<#pragma omp cancel must specify one of " + error_at (loc, "%<#pragma omp cancel%> must specify one of " "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> " "clauses"); return; @@ -11972,7 +11972,7 @@ c_finish_omp_cancellation_point (location_t loc, tree clauses) mask = 8; else { - error_at (loc, "%<#pragma omp cancellation point must specify one of " + error_at (loc, "%<#pragma omp cancellation point%> must specify one of " "%<parallel%>, %<for%>, %<sections%> or %<taskgroup%> " "clauses"); return; |