Commit a04e69c0 by Thomas Schwinge Committed by Thomas Schwinge

Tighten syntax checking for OpenACC routine construct in C

	gcc/c/
	* c-parser.c (c_parser_oacc_routine): Tighten syntax checks.
	gcc/testsuite/
	* c-c++-common/goacc/routine-5.c: Add tests.
	* g++.dg/goacc/routine-2.C: Remove duplicate tests.
	* gfortran.dg/goacc/routine-6.f90: Add tests.

From-SVN: r236639
parent d4b5c77d
2016-05-24 Thomas Schwinge <thomas@codesourcery.com>
* c-parser.c (c_parser_oacc_routine): Tighten syntax checks.
2016-05-24 Richard Biener <rguenther@suse.de>
PR middle-end/70434
......
......@@ -13983,25 +13983,24 @@ c_parser_oacc_routine (c_parser *parser, enum pragma_context context)
c_parser_consume_token (parser);
c_token *token = c_parser_peek_token (parser);
if (token->type == CPP_NAME && (token->id_kind == C_ID_ID
|| token->id_kind == C_ID_TYPENAME))
{
decl = lookup_name (token->value);
if (!decl)
{
error_at (token->location, "%qE has not been declared",
token->value);
decl = error_mark_node;
}
c_parser_consume_token (parser);
}
else
c_parser_error (parser, "expected function name");
if (token->type != CPP_CLOSE_PAREN)
c_parser_consume_token (parser);
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, 0);
if (!decl
|| !c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
{
c_parser_skip_to_pragma_eol (parser, false);
return;
}
}
/* Build a chain of clauses. */
......
2016-05-24 Thomas Schwinge <thomas@codesourcery.com>
* c-c++-common/goacc/routine-5.c: Add tests.
* g++.dg/goacc/routine-2.C: Remove duplicate tests.
* gfortran.dg/goacc/routine-6.f90: Add tests.
2016-05-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/71253
......
......@@ -38,13 +38,26 @@ namespace g {}
#pragma acc routine /* { dg-error "not followed by" "" { target c++ } } */
using namespace g;
#pragma acc routine (g) /* { dg-error "does not refer to" "" { target c++ } } */
#pragma acc routine (g) /* { dg-error "does not refer to a function" "" { target c++ } } */
#endif
#endif /* __cplusplus */
#pragma acc routine (a) /* { dg-error "does not refer to" } */
#pragma acc routine (a) /* { dg-error "does not refer to a function" } */
#pragma acc routine (c) /* { dg-error "does not refer to" } */
#pragma acc routine (c) /* { dg-error "does not refer to a function" } */
#pragma acc routine () vector /* { dg-error "expected (function name|unqualified-id) before .\\). token" } */
#pragma acc routine (+) /* { dg-error "expected (function name|unqualified-id) before .\\+. token" } */
extern void R1(void);
extern void R2(void);
#pragma acc routine (R1, R2, R3) worker /* { dg-error "expected .\\). before .,. token" } */
#pragma acc routine (R1 R2 R3) worker /* { dg-error "expected .\\). before .R2." } */
#pragma acc routine (R1) worker
#pragma acc routine (R2) worker
void Bar ();
......
......@@ -14,15 +14,9 @@ one()
int incr (int);
float incr (float);
int inc;
#pragma acc routine (incr) /* { dg-error "names a set of overloads" } */
#pragma acc routine (increment) /* { dg-error "has not been declared" } */
#pragma acc routine (inc) /* { dg-error "does not refer to a function" } */
#pragma acc routine (+) /* { dg-error "expected unqualified-id before '.' token" } */
int sum (int, int);
......
......@@ -29,6 +29,13 @@ program main
!$acc routine (subr1) ! { dg-error "invalid function name" }
external :: subr2
!$acc routine (subr2)
external :: R1, R2
!$acc routine (R1 R2 R3) ! { dg-error "Syntax error in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), expecting .\\). after NAME" }
!$acc routine (R1, R2, R3) ! { dg-error "Syntax error in \\!\\\$ACC ROUTINE \\( NAME \\) at \\(1\\), expecting .\\). after NAME" }
!$acc routine (R1)
!$acc routine (R2)
!$acc parallel
!$acc loop
do i = 1, n
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment