From: Jakub Jelinek Date: Tue, 7 Mar 2017 19:07:44 +0000 (+0100) Subject: re PR c/79834 (c/c-parser.c: make code more i18n-friendly) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a71dbc63406e497eb2c1ce395bc90c8facfde89b;p=gcc.git re PR c/79834 (c/c-parser.c: make code more i18n-friendly) PR c/79834 c/ * c-parser.c (c_parser_pragma): Use error_at instead of c_parser_error for "may only be used in compound statements" diagnostics, change it such that the same translatable string is used for all pragmas. For PRAGMA_OACC_WAIT use "acc wait" rather than "acc enter data" in the diagnostics. (c_parser_omp_cancellation_point, c_parser_omp_target_update, c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Change "may only be used in compound statements" diagnostics, such that the same translatable string is used for all pragmas. cp/ * parser.c (cp_parser_omp_cancellation_point, cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data, cp_parser_omp_target_update): Change "may only be used in compound statements" diagnostics, such that the same translatable string is used for all pragmas. (cp_parser_pragma): Likewise. Use error_at instead of cp_parser_error for that diagnostics. testsuite/ * c-c++-common/goacc/pragma_context.c (f2): Adjust expected diagnostics. From-SVN: r245959 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index e639e6bb785..588fe73f660 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,16 @@ +2017-03-07 Jakub Jelinek + + PR c/79834 + * c-parser.c (c_parser_pragma): Use error_at instead of c_parser_error + for "may only be used in compound statements" diagnostics, change it + such that the same translatable string is used for all pragmas. For + PRAGMA_OACC_WAIT use "acc wait" rather than "acc enter data" in the + diagnostics. + (c_parser_omp_cancellation_point, c_parser_omp_target_update, + c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Change + "may only be used in compound statements" diagnostics, such that the + same translatable string is used for all pragmas. + 2017-03-04 Marek Polacek PR c/79847 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index fa4e950c94f..8330e65fc94 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -10157,6 +10157,7 @@ static bool c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) { unsigned int id; + const char *construct = NULL; id = c_parser_peek_token (parser)->pragma_kind; gcc_assert (id != PRAGMA_NONE); @@ -10170,9 +10171,16 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_ENTER_DATA: if (context != pragma_compound) { + construct = "acc enter data"; + in_compound: if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma acc enter data%> may only be " - "used in compound statements"); + { + error_at (c_parser_peek_token (parser)->location, + "%<#pragma %s%> may only be used in compound " + "statements", construct); + c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL); + return false; + } goto bad_stmt; } c_parser_oacc_enter_exit_data (parser, true); @@ -10181,10 +10189,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_EXIT_DATA: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma acc exit data%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "acc exit data"; + goto in_compound; } c_parser_oacc_enter_exit_data (parser, false); return false; @@ -10203,10 +10209,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_UPDATE: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma acc update%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "acc update"; + goto in_compound; } c_parser_oacc_update (parser); return false; @@ -10214,10 +10218,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OMP_BARRIER: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma omp barrier%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "omp barrier"; + goto in_compound; } c_parser_omp_barrier (parser); return false; @@ -10225,10 +10227,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OMP_FLUSH: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma omp flush%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "omp flush"; + goto in_compound; } c_parser_omp_flush (parser); return false; @@ -10236,10 +10236,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OMP_TASKWAIT: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma omp taskwait%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "omp taskwait"; + goto in_compound; } c_parser_omp_taskwait (parser); return false; @@ -10247,10 +10245,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OMP_TASKYIELD: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma omp taskyield%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "omp taskyield"; + goto in_compound; } c_parser_omp_taskyield (parser); return false; @@ -10258,10 +10254,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OMP_CANCEL: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma omp cancel%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "omp cancel"; + goto in_compound; } c_parser_omp_cancel (parser); return false; @@ -10345,10 +10339,8 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_WAIT: if (context != pragma_compound) { - if (context == pragma_stmt) - c_parser_error (parser, "%<#pragma acc enter data%> may only be " - "used in compound statements"); - goto bad_stmt; + construct = "acc wait"; + goto in_compound; } /* FALL THROUGH. */ @@ -15864,8 +15856,9 @@ c_parser_omp_cancellation_point (c_parser *parser, enum pragma_context context) if (context != pragma_compound) { if (context == pragma_stmt) - error_at (loc, "%<#pragma omp cancellation point%> may only be used in" - " compound statements"); + error_at (loc, + "%<#pragma %s%> may only be used in compound statements", + "omp cancellation point"); else c_parser_error (parser, "expected declaration specifiers"); c_parser_skip_to_pragma_eol (parser, false); @@ -16122,9 +16115,8 @@ c_parser_omp_target_update (location_t loc, c_parser *parser, { if (context == pragma_stmt) { - error_at (loc, - "%<#pragma omp target update%> may only be " - "used in compound statements"); + error_at (loc, "%<#pragma %s%> may only be used in compound statements", + "omp target update"); c_parser_skip_to_pragma_eol (parser, false); return false; } @@ -16182,9 +16174,8 @@ c_parser_omp_target_enter_data (location_t loc, c_parser *parser, if (context == pragma_stmt) { - error_at (loc, - "%<#pragma omp target enter data%> may only be " - "used in compound statements"); + error_at (loc, "%<#pragma %s%> may only be used in compound statements", + "omp target enter data"); c_parser_skip_to_pragma_eol (parser, false); return NULL_TREE; } @@ -16267,9 +16258,8 @@ c_parser_omp_target_exit_data (location_t loc, c_parser *parser, if (context == pragma_stmt) { - error_at (loc, - "%<#pragma omp target exit data%> may only be " - "used in compound statements"); + error_at (loc, "%<#pragma %s%> may only be used in compound statements", + "omp target exit data"); c_parser_skip_to_pragma_eol (parser, false); return NULL_TREE; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 13350b8b347..47add3250d5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2017-03-07 Jakub Jelinek + + PR c/79834 + * parser.c (cp_parser_omp_cancellation_point, + cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data, + cp_parser_omp_target_update): Change "may only be used in compound + statements" diagnostics, such that the same translatable string is + used for all pragmas. + (cp_parser_pragma): Likewise. Use error_at instead of + cp_parser_error for that diagnostics. + 2017-03-06 Marek Polacek PR c++/79796 - ICE with NSDMI and this pointer diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e6848701150..c1b6496af4b 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -35341,8 +35341,8 @@ cp_parser_omp_cancellation_point (cp_parser *parser, cp_token *pragma_tok, { if (context == pragma_stmt) error_at (pragma_tok->location, - "%<#pragma omp cancellation point%> may only be used in" - " compound statements"); + "%<#pragma %s%> may only be used in compound statements", + "omp cancellation point"); else cp_parser_error (parser, "expected declaration specifiers"); cp_parser_skip_to_pragma_eol (parser, pragma_tok); @@ -35635,8 +35635,8 @@ cp_parser_omp_target_enter_data (cp_parser *parser, cp_token *pragma_tok, if (context == pragma_stmt) { error_at (pragma_tok->location, - "%<#pragma omp target enter data%> may only be " - "used in compound statements"); + "%<#pragma %s%> may only be used in compound statements", + "omp target enter data"); cp_parser_skip_to_pragma_eol (parser, pragma_tok); return NULL_TREE; } @@ -35723,8 +35723,8 @@ cp_parser_omp_target_exit_data (cp_parser *parser, cp_token *pragma_tok, if (context == pragma_stmt) { error_at (pragma_tok->location, - "%<#pragma omp target exit data%> may only be " - "used in compound statements"); + "%<#pragma %s%> may only be used in compound statements", + "omp target exit data"); cp_parser_skip_to_pragma_eol (parser, pragma_tok); return NULL_TREE; } @@ -35794,8 +35794,8 @@ cp_parser_omp_target_update (cp_parser *parser, cp_token *pragma_tok, if (context == pragma_stmt) { error_at (pragma_tok->location, - "%<#pragma omp target update%> may only be " - "used in compound statements"); + "%<#pragma %s%> may only be used in compound statements", + "omp target update"); cp_parser_skip_to_pragma_eol (parser, pragma_tok); return false; } @@ -38105,8 +38105,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) cp_parser_omp_barrier (parser, pragma_tok); return false; case pragma_stmt: - error_at (pragma_tok->location, "%<#pragma omp barrier%> may only be " - "used in compound statements"); + error_at (pragma_tok->location, "%<#pragma %s%> may only be " + "used in compound statements", "omp barrier"); break; default: goto bad_stmt; @@ -38120,8 +38120,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) cp_parser_omp_flush (parser, pragma_tok); return false; case pragma_stmt: - error_at (pragma_tok->location, "%<#pragma omp flush%> may only be " - "used in compound statements"); + error_at (pragma_tok->location, "%<#pragma %s%> may only be " + "used in compound statements", "omp flush"); break; default: goto bad_stmt; @@ -38136,8 +38136,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) return false; case pragma_stmt: error_at (pragma_tok->location, - "%<#pragma omp taskwait%> may only be " - "used in compound statements"); + "%<#pragma %s%> may only be used in compound statements", + "omp taskwait"); break; default: goto bad_stmt; @@ -38152,8 +38152,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) return false; case pragma_stmt: error_at (pragma_tok->location, - "%<#pragma omp taskyield%> may only be " - "used in compound statements"); + "%<#pragma %s%> may only be used in compound statements", + "omp taskyield"); break; default: goto bad_stmt; @@ -38168,8 +38168,8 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) return false; case pragma_stmt: error_at (pragma_tok->location, - "%<#pragma omp cancel%> may only be " - "used in compound statements"); + "%<#pragma %s%> may only be used in compound statements", + "omp cancel"); break; default: goto bad_stmt; @@ -38195,8 +38195,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_ENTER_DATA: if (context == pragma_stmt) { - cp_parser_error (parser, "%<#pragma acc enter data%> may only be " - "used in compound statements"); + error_at (pragma_tok->location, + "%<#pragma %s%> may only be used in compound statements", + "acc enter data"); break; } else if (context != pragma_compound) @@ -38207,8 +38208,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_EXIT_DATA: if (context == pragma_stmt) { - cp_parser_error (parser, "%<#pragma acc exit data%> may only be " - "used in compound statements"); + error_at (pragma_tok->location, + "%<#pragma %s%> may only be used in compound statements", + "acc exit data"); break; } else if (context != pragma_compound) @@ -38229,8 +38231,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_UPDATE: if (context == pragma_stmt) { - cp_parser_error (parser, "%<#pragma acc update%> may only be " - "used in compound statements"); + error_at (pragma_tok->location, + "%<#pragma %s%> may only be used in compound statements", + "acc update"); break; } else if (context != pragma_compound) @@ -38241,8 +38244,9 @@ cp_parser_pragma (cp_parser *parser, enum pragma_context context, bool *if_p) case PRAGMA_OACC_WAIT: if (context == pragma_stmt) { - cp_parser_error (parser, "%<#pragma acc wait%> may only be " - "used in compound statements"); + error_at (pragma_tok->location, + "%<#pragma %s%> may only be used in compound statements", + "acc wait"); break; } else if (context != pragma_compound) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ce63eb0dfde..bfff262e048 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-03-07 Jakub Jelinek + + PR c/79834 + * c-c++-common/goacc/pragma_context.c (f2): Adjust expected + diagnostics. + 2017-03-07 Marek Polacek PR middle-end/79809 diff --git a/gcc/testsuite/c-c++-common/goacc/pragma_context.c b/gcc/testsuite/c-c++-common/goacc/pragma_context.c index 680dc9bba0e..fe50b75304b 100644 --- a/gcc/testsuite/c-c++-common/goacc/pragma_context.c +++ b/gcc/testsuite/c-c++-common/goacc/pragma_context.c @@ -22,7 +22,7 @@ void f2 (void) { if (0) -#pragma acc update /* { dg-error "'#pragma acc update' may only be used in compound statements before '#pragma'" } */ +#pragma acc update /* { dg-error "'#pragma acc update' may only be used in compound statements" } */ } // pragma_compound