From: Thomas Schwinge <tho...@codesourcery.com>

        gcc/c-family/
        * c-pragma.c (oacc_pragmas): New array.
        (c_pp_lookup_pragma, init_pragma): Handle it.
        gcc/
        * doc/invoke.texi (-fopenacc): Update.

        gcc/c/
        * c-parser.c (c_parser_omp_all_clauses): Make a parser error
        message suitable for OpenACC, too.
        gcc/cp/
        * parser.c (cp_parser_omp_all_clauses): Make a parser error
        message suitable for OpenACC, too.
---
 gcc/c-family/c-pragma.c | 22 ++++++++++++++++++++++
 gcc/c/c-parser.c        |  2 +-
 gcc/cp/parser.c         |  2 +-
 gcc/doc/invoke.texi     |  2 +-
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git gcc/c-family/c-pragma.c gcc/c-family/c-pragma.c
index 3ce77a2..98f98d0 100644
--- gcc/c-family/c-pragma.c
+++ gcc/c-family/c-pragma.c
@@ -1164,6 +1164,8 @@ typedef struct
 static vec<pragma_ns_name> registered_pp_pragmas;
 
 struct omp_pragma_def { const char *name; unsigned int id; };
+static const struct omp_pragma_def oacc_pragmas[] = {
+};
 static const struct omp_pragma_def omp_pragmas[] = {
   { "atomic", PRAGMA_OMP_ATOMIC },
   { "barrier", PRAGMA_OMP_BARRIER },
@@ -1194,9 +1196,18 @@ static const struct omp_pragma_def omp_pragmas[] = {
 void
 c_pp_lookup_pragma (unsigned int id, const char **space, const char **name)
 {
+  const int n_oacc_pragmas = sizeof (oacc_pragmas) / sizeof (*oacc_pragmas);
   const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
   int i;
 
+  for (i = 0; i < n_oacc_pragmas; ++i)
+    if (oacc_pragmas[i].id == id)
+      {
+       *space = "acc";
+       *name = oacc_pragmas[i].name;
+       return;
+      }
+
   for (i = 0; i < n_omp_pragmas; ++i)
     if (omp_pragmas[i].id == id)
       {
@@ -1348,6 +1359,17 @@ c_invoke_pragma_handler (unsigned int id)
 void
 init_pragma (void)
 {
+  if (flag_openacc)
+    {
+      const int n_oacc_pragmas
+       = sizeof (oacc_pragmas) / sizeof (*oacc_pragmas);
+      int i;
+
+      for (i = 0; i < n_oacc_pragmas; ++i)
+       cpp_register_deferred_pragma (parse_in, "acc", oacc_pragmas[i].name,
+                                     oacc_pragmas[i].id, true, true);
+    }
+
   if (flag_openmp)
     {
       const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);
diff --git gcc/c/c-parser.c gcc/c/c-parser.c
index a8f4774..8a1e988 100644
--- gcc/c/c-parser.c
+++ gcc/c/c-parser.c
@@ -10730,7 +10730,7 @@ c_parser_omp_all_clauses (c_parser *parser, 
omp_clause_mask mask,
          c_name = "simdlen";
          break;
        default:
-         c_parser_error (parser, "expected %<#pragma omp%> clause");
+         c_parser_error (parser, "expected clause");
          goto saw_error;
        }
 
diff --git gcc/cp/parser.c gcc/cp/parser.c
index bbc8e75..c3345ee 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -27911,7 +27911,7 @@ cp_parser_omp_all_clauses (cp_parser *parser, 
omp_clause_mask mask,
          c_name = "simdlen";
          break;
        default:
-         cp_parser_error (parser, "expected %<#pragma omp%> clause");
+         cp_parser_error (parser, "expected clause");
          goto saw_error;
        }
 
diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi
index af8973a..cc4a6da 100644
--- gcc/doc/invoke.texi
+++ gcc/doc/invoke.texi
@@ -1835,7 +1835,7 @@ freestanding and hosted environments.
 @item -fopenacc
 @opindex fopenacc
 @cindex OpenACC accelerator programming
-Enable handling of OpenACC.
+Enable handling of OpenACC directives @code{#pragma acc} in C.
 When @option{-fopenacc} is specified, the
 compiler generates accelerated code according to the OpenACC Application
 Programming Interface v2.0 @w{@uref{http://www.openacc.org/}}.  This option
-- 
1.8.1.1

Reply via email to