@@ -31339,7 +31339,10 @@ cp_parser_omp_var_list_no_open (cp_parse
if (name == error_mark_node)
goto skip_comma;
- decl = cp_parser_lookup_name_simple (parser, name, token->location);
+ if (identifier_p (name))
+ decl = cp_parser_lookup_name_simple (parser, name, token->location);
+ else
+ decl = name;
if (decl == error_mark_node)
cp_parser_name_lookup_error (parser, name, decl, NLE_NULL,
token->location);
@@ -37843,7 +37846,9 @@ cp_parser_oacc_routine (cp_parser *parse
/*template_p=*/NULL,
/*declarator_p=*/false,
/*optional_p=*/false);
- tree decl = cp_parser_lookup_name_simple (parser, name, name_loc);
+ tree decl = (identifier_p (name)
+ ? cp_parser_lookup_name_simple (parser, name, name_loc)
+ : name);
if (name != error_mark_node && decl == error_mark_node)
cp_parser_name_lookup_error (parser, name, decl, NLE_NULL, name_loc);
@@ -0,0 +1,14 @@
+// PR c++/84557
+// { dg-do compile }
+
+template<int> struct A {};
+template<int> struct B {};
+
+void
+foo ()
+{
+ #pragma omp parallel firstprivate (A) // { dg-error "is not a variable in clause" }
+ ;
+ #pragma omp parallel firstprivate (B<0>) // { dg-error "is not a variable in clause" }
+ ;
+}