+2016-12-02 Cesar Philippidis <cesar@codesourcery.com>
+ James Norris <jnorris@codesourcery.com>
+
+ * c-parser.c (c_parser_pragma): Error when PRAGMA_OACC_{ENTER_DATA,
+ EXIT_DATA,WAIT} are not used in compound statements.
+ (c_parser_oacc_enter_exit_data): Update diagnostics.
+
2016-11-21 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR c++/71973
return false;
case PRAGMA_OACC_ENTER_DATA:
+ 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;
+ }
c_parser_oacc_enter_exit_data (parser, true);
return false;
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;
+ }
c_parser_oacc_enter_exit_data (parser, false);
return false;
c_parser_cilk_grainsize (parser, if_p);
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;
+ }
+ /* FALL THROUGH. */
+
default:
if (id < PRAGMA_FIRST_EXTERNAL)
{
{
location_t loc = c_parser_peek_token (parser)->location;
tree clauses, stmt;
+ const char *p = "";
c_parser_consume_pragma (parser);
- if (!c_parser_next_token_is (parser, CPP_NAME))
+ if (c_parser_next_token_is (parser, CPP_NAME))
{
- c_parser_error (parser, enter
- ? "expected %<data%> in %<#pragma acc enter data%>"
- : "expected %<data%> in %<#pragma acc exit data%>");
- c_parser_skip_to_pragma_eol (parser);
- return;
+ p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
+ c_parser_consume_token (parser);
}
- const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
if (strcmp (p, "data") != 0)
{
- c_parser_error (parser, "invalid pragma");
+ error_at (loc, enter
+ ? "expected %<data%> after %<#pragma acc enter%>"
+ : "expected %<data%> after %<#pragma acc exit%>");
+ parser->error = true;
c_parser_skip_to_pragma_eol (parser);
return;
}
- c_parser_consume_token (parser);
-
if (enter)
clauses = c_parser_oacc_all_clauses (parser, OACC_ENTER_DATA_CLAUSE_MASK,
"#pragma acc enter data");
+2016-12-02 Cesar Philippidis <cesar@codesourcery.com>
+ James Norris <jnorris@codesourcery.com>
+
+ * parser.c (cp_parser_oacc_enter_exit_data): Update diagnostics.
+ (cp_parser_pragma): Error when PRAGMA_OACC_{ENTER_DATA,
+ EXIT_DATA,WAIT} are not used in compound statements.
+
2016-12-01 Jason Merrill <jason@redhat.com>
* call.c (add_function_candidate): Also exclude inherited ctors
cp_parser_oacc_enter_exit_data (cp_parser *parser, cp_token *pragma_tok,
bool enter)
{
+ location_t loc = pragma_tok->location;
tree stmt, clauses;
+ const char *p = "";
- if (cp_lexer_next_token_is (parser->lexer, CPP_PRAGMA_EOL)
- || cp_lexer_next_token_is_not (parser->lexer, CPP_NAME))
- {
- cp_parser_error (parser, enter
- ? "expected %<data%> in %<#pragma acc enter data%>"
- : "expected %<data%> in %<#pragma acc exit data%>");
- cp_parser_skip_to_pragma_eol (parser, pragma_tok);
- return NULL_TREE;
- }
+ if (cp_lexer_next_token_is (parser->lexer, CPP_NAME))
+ p = IDENTIFIER_POINTER (cp_lexer_peek_token (parser->lexer)->u.value);
- const char *p =
- IDENTIFIER_POINTER (cp_lexer_peek_token (parser->lexer)->u.value);
if (strcmp (p, "data") != 0)
{
- cp_parser_error (parser, "invalid pragma");
+ error_at (loc, enter
+ ? "expected %<data%> after %<#pragma acc enter%>"
+ : "expected %<data%> after %<#pragma acc exit%>");
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return NULL_TREE;
}
if (find_omp_clause (clauses, OMP_CLAUSE_MAP) == NULL_TREE)
{
- error_at (pragma_tok->location,
- "%<#pragma acc enter data%> has no data movement clause");
+ error_at (loc, "%<#pragma acc %s data%> has no data movement clause",
+ enter ? "enter" : "exit");
return NULL_TREE;
}
cp_parser_oacc_declare (parser, pragma_tok);
return false;
+ case PRAGMA_OACC_ENTER_DATA:
+ if (context == pragma_stmt)
+ {
+ cp_parser_error (parser, "%<#pragma acc enter data%> may only be "
+ "used in compound statements");
+ break;
+ }
+ else if (context != pragma_compound)
+ goto bad_stmt;
+ cp_parser_omp_construct (parser, pragma_tok, if_p);
+ return true;
+
+ case PRAGMA_OACC_EXIT_DATA:
+ if (context == pragma_stmt)
+ {
+ cp_parser_error (parser, "%<#pragma acc exit data%> may only be "
+ "used in compound statements");
+ break;
+ }
+ else if (context != pragma_compound)
+ goto bad_stmt;
+ cp_parser_omp_construct (parser, pragma_tok, if_p);
+ return true;
+
case PRAGMA_OACC_ROUTINE:
if (context != pragma_external)
{
cp_parser_oacc_routine (parser, pragma_tok, context);
return false;
+ case PRAGMA_OACC_UPDATE:
+ if (context == pragma_stmt)
+ {
+ cp_parser_error (parser, "%<#pragma acc update%> may only be "
+ "used in compound statements");
+ break;
+ }
+ else if (context != pragma_compound)
+ goto bad_stmt;
+ cp_parser_omp_construct (parser, pragma_tok, if_p);
+ return true;
+
+ case PRAGMA_OACC_WAIT:
+ if (context == pragma_stmt)
+ {
+ cp_parser_error (parser, "%<#pragma acc wait%> may only be "
+ "used in compound statements");
+ break;
+ }
+ else if (context != pragma_compound)
+ goto bad_stmt;
+ cp_parser_omp_construct (parser, pragma_tok, if_p);
+ return true;
+
case PRAGMA_OACC_ATOMIC:
case PRAGMA_OACC_CACHE:
case PRAGMA_OACC_DATA:
- case PRAGMA_OACC_ENTER_DATA:
- case PRAGMA_OACC_EXIT_DATA:
case PRAGMA_OACC_HOST_DATA:
case PRAGMA_OACC_KERNELS:
case PRAGMA_OACC_PARALLEL:
case PRAGMA_OACC_LOOP:
- case PRAGMA_OACC_UPDATE:
- case PRAGMA_OACC_WAIT:
case PRAGMA_OMP_ATOMIC:
case PRAGMA_OMP_CRITICAL:
case PRAGMA_OMP_DISTRIBUTE:
+2016-12-02 Cesar Philippidis <cesar@codesourcery.com>
+ James Norris <jnorris@codesourcery.com>
+
+ * c-c++-common/goacc/data-2.c: Adjust test.
+ * c-c++-common/goacc/executeables-1.c: New test.
+ * g++.dg/goacc/data-1.C: Adjust test.
+
2016-12-02 James Greenhalgh <james.greenhalgh@arm.com>
PR rtl-optimization/78561
#pragma acc exit data delete (a) if (0)
#pragma acc exit data copyout (b) if (a)
#pragma acc exit data delete (b)
-#pragma acc enter /* { dg-error "expected 'data' in" } */
-#pragma acc exit /* { dg-error "expected 'data' in" } */
+#pragma acc enter /* { dg-error "expected 'data' after" } */
+#pragma acc exit /* { dg-error "expected 'data' after" } */
#pragma acc enter data /* { dg-error "has no data movement clause" } */
-#pragma acc exit data /* { dg-error "has no data movement clause" } */
-#pragma acc enter Data /* { dg-error "invalid pragma before" } */
-#pragma acc exit copyout (b) /* { dg-error "invalid pragma before" } */
+#pragma acc exit data /* { dg-error "no data movement clause" } */
+#pragma acc enter Data /* { dg-error "expected 'data' after" } */
+#pragma acc exit copyout (b) /* { dg-error "expected 'data' after" } */
+#pragma acc enter for /* { dg-error "expected 'data' after" } */
+#pragma acc enter data2 /* { dg-error "expected 'data' after" } */
}
/* { dg-error "has no data movement clause" "" { target *-*-* } 8 } */
--- /dev/null
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+ const int N = 32;
+ float x[N], y[N];
+ int flag = 0;
+
+ if (flag)
+#pragma acc update host (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+
+ while (flag)
+#pragma acc update host (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 2;
+
+#pragma acc enter data create (x[0:N])
+ {
+ if (flag)
+#pragma acc update host (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+ }
+
+ if (flag)
+ while (flag)
+#pragma acc update host (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 2;
+
+ if (flag)
+#pragma acc wait /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+
+ while (flag)
+#pragma acc wait /* { dg-error "may only be used in compound statements" } */
+ flag = 2;
+
+#pragma acc enter data create (x[0:N])
+ {
+ if (flag)
+#pragma acc wait /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+ }
+
+ if (flag)
+#pragma acc enter data create (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+
+ while (flag)
+#pragma acc enter data create (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 2;
+
+#pragma acc enter data create (x[0:N])
+ {
+ if (flag)
+#pragma acc enter data create (y[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+ }
+
+ if (flag)
+#pragma acc exit data delete (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+
+ while (flag)
+#pragma acc exit data delete (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 2;
+
+#pragma acc enter data create (x[0:N])
+ {
+ if (flag)
+#pragma acc exit data delete (x[0:N]) /* { dg-error "may only be used in compound statements" } */
+ flag = 1;
+ }
+}
#pragma acc exit data delete (a) if (0)
#pragma acc exit data copyout (b) if (a)
#pragma acc exit data delete (b)
-#pragma acc enter /* { dg-error "expected 'data' in" } */
-#pragma acc exit /* { dg-error "expected 'data' in" } */
+#pragma acc enter /* { dg-error "expected 'data' after" } */
+#pragma acc exit /* { dg-error "expected 'data' after" } */
#pragma acc enter data /* { dg-error "has no data movement clause" } */
#pragma acc exit data /* { dg-error "has no data movement clause" } */
-#pragma acc enter Data /* { dg-error "invalid pragma before" } */
-#pragma acc exit copyout (b) /* { dg-error "invalid pragma before" } */
+#pragma acc enter Data /* { dg-error "expected 'data' after" } */
+#pragma acc exit copyout (b) /* { dg-error "expected 'data' after" } */
}
template<typename T>
#pragma acc exit data delete (a) if (0)
#pragma acc exit data copyout (b) if (a)
#pragma acc exit data delete (b)
-#pragma acc enter /* { dg-error "expected 'data' in" } */
-#pragma acc exit /* { dg-error "expected 'data' in" } */
+#pragma acc enter /* { dg-error "expected 'data' after" } */
+#pragma acc exit /* { dg-error "expected 'data' after" } */
#pragma acc enter data /* { dg-error "has no data movement clause" } */
#pragma acc exit data /* { dg-error "has no data movement clause" } */
-#pragma acc enter Data /* { dg-error "invalid pragma before" } */
-#pragma acc exit copyout (b) /* { dg-error "invalid pragma before" } */
+#pragma acc enter Data /* { dg-error "expected 'data' after" } */
+#pragma acc exit copyout (b) /* { dg-error "expected 'data' after" } */
}
/* { dg-error "has no data movement clause" "" { target *-*-* } 6 } */