+2017-03-07 Jakub Jelinek <jakub@redhat.com>
+
+ 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 <polacek@redhat.com>
PR c/79847
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);
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);
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;
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;
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;
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;
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;
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;
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;
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. */
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);
{
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;
}
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;
}
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;
}
+2017-03-07 Jakub Jelinek <jakub@redhat.com>
+
+ 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 <polacek@redhat.com>
PR c++/79796 - ICE with NSDMI and this pointer
{
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);
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;
}
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;
}
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;
}
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;
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;
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;
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;
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;
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)
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)
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)
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)
+2017-03-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/79834
+ * c-c++-common/goacc/pragma_context.c (f2): Adjust expected
+ diagnostics.
+
2017-03-07 Marek Polacek <polacek@redhat.com>
PR middle-end/79809
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