re PR c++/84557 (ICE with invalid firstprivate variable)
authorJakub Jelinek <jakub@redhat.com>
Mon, 26 Feb 2018 19:51:05 +0000 (20:51 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 26 Feb 2018 19:51:05 +0000 (20:51 +0100)
PR c++/84557
* parser.c (cp_parser_omp_var_list_no_open): Only call
cp_parser_lookup_name_simple on names satisfying identifier_p.
(cp_parser_oacc_routine): Likewise.

* g++.dg/gomp/pr84557.C: New test.

From-SVN: r258011

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr84557.C [new file with mode: 0644]

index bf995f0..94f684b 100644 (file)
@@ -1,3 +1,10 @@
+2018-02-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84557
+       * parser.c (cp_parser_omp_var_list_no_open): Only call
+       cp_parser_lookup_name_simple on names satisfying identifier_p.
+       (cp_parser_oacc_routine): Likewise.
+
 2018-02-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/84551 - ICE with concepts and -g.
index f305c9c..bcee121 100644 (file)
@@ -31342,7 +31342,10 @@ cp_parser_omp_var_list_no_open (cp_parser *parser, enum omp_clause_code kind,
          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);
@@ -37846,7 +37849,9 @@ cp_parser_oacc_routine (cp_parser *parser, cp_token *pragma_tok,
                                           /*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);
 
index 6fd236c..9ebfd3e 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84557
+       * g++.dg/gomp/pr84557.C: New test.
+
 2018-02-26  Marek Polacek  <polacek@redhat.com>
 
        PR c++/84325
diff --git a/gcc/testsuite/g++.dg/gomp/pr84557.C b/gcc/testsuite/g++.dg/gomp/pr84557.C
new file mode 100644 (file)
index 0000000..cd21590
--- /dev/null
@@ -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" }
+  ;
+}