@@ -13989,8 +13989,21 @@ c_parser_oacc_routine (c_parser *parser, enum pragma_context context)
{
decl = lookup_name (token->value);
if (!decl)
- error_at (token->location, "%qE has not been declared",
- token->value);
+ {
+ error_at (token->location, "%qE has not been declared",
+ token->value);
+ static bool informed_once = false;
+ if (!informed_once)
+ {
+ inform (token->location,
+ "if the routine directive is meant to apply to the "
+ "lexically following function declaration or "
+ "definition, either don't specify %<(%E)%> here, or "
+ "place a function declaration before the directive",
+ token->value);
+ informed_once = true;
+ }
+ }
c_parser_consume_token (parser);
}
else
@@ -36504,8 +36504,21 @@ cp_parser_oacc_routine (cp_parser *parser, cp_token *pragma_tok,
/*optional_p=*/false);
decl = cp_parser_lookup_name_simple (parser, id, token->location);
if (id != error_mark_node && decl == error_mark_node)
- cp_parser_name_lookup_error (parser, id, decl, NLE_NULL,
- token->location);
+ {
+ cp_parser_name_lookup_error (parser, id, decl, NLE_NULL,
+ token->location);
+ static bool informed_once = false;
+ if (!informed_once)
+ {
+ inform (token->location,
+ "if the routine directive is meant to apply to the "
+ "lexically following function declaration or "
+ "definition, either don't specify %<(%E)%> here, or "
+ "place a function declaration before the directive",
+ id);
+ informed_once = true;
+ }
+ }
if (decl == error_mark_node
|| !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN))
@@ -71,7 +71,20 @@ void Foo ()
#pragma acc routine (Foo) gang // { dg-error "must be applied before definition" }
-#pragma acc routine (Baz) // { dg-error "not been declared" }
+#pragma acc routine (Baz) worker
+/* { dg-error ".Baz. has not been declared" "" { target *-*-* } 74 }
+ Try to help the user:
+ { dg-message "note: if the routine directive" "" { target *-*-* } 74 } */
+
+#pragma acc routine (Baz) vector
+/* { dg-error ".Baz. has not been declared" "" { target *-*-* } 79 }
+ Don't try to help the user again:
+ { dg-bogus "note: if the routine directive" "" { target *-*-* } 79 } */
+
+#pragma acc routine (Qux) seq
+/* { dg-error ".Qux. has not been declared" "" { target *-*-* } 84 }
+ Don't try to help the user again:
+ { dg-bogus "note: if the routine directive" "" { target *-*-* } 84 } */
int vb1; /* { dg-error "directive for use" } */