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

        gcc/c-family/
        * c-cppbuiltin.c (c_cpp_builtins): Conditionally define _OPENACC.
        gcc/fortran/
        * cpp.c (cpp_define_builtins): Conditionally define _OPENACC.
        gcc/testsuite/
        * c-c++-common/cpp/openacc-define-1.c: Test _OPENACC.
        * c-c++-common/cpp/openacc-define-2.c: Likewise.
        * c-c++-common/cpp/openacc-define-3.c: Likewise.
        * gfortran.dg/openacc-define-1.f90: Likewise.
        * gfortran.dg/openacc-define-2.f90: Likewise.
        * gfortran.dg/openacc-define-3.f90: Likewise.
        libgomp/
        * openacc.f90 (openacc_version): New integer parameter.
        * openacc_lib.h (openacc_version): Likewise.
        * testsuite/libgomp.oacc-fortran/openacc_version-1.f: New file.
        * testsuite/libgomp.oacc-fortran/openacc_version-2.f90: Likewise.
---
 gcc/c-family/c-cppbuiltin.c                                  | 3 +++
 gcc/fortran/cpp.c                                            | 3 +++
 gcc/testsuite/c-c++-common/cpp/openacc-define-1.c            | 4 ++++
 gcc/testsuite/c-c++-common/cpp/openacc-define-2.c            | 4 ++++
 gcc/testsuite/c-c++-common/cpp/openacc-define-3.c            | 8 ++++++++
 gcc/testsuite/gfortran.dg/openacc-define-1.f90               | 4 ++++
 gcc/testsuite/gfortran.dg/openacc-define-2.f90               | 4 ++++
 gcc/testsuite/gfortran.dg/openacc-define-3.f90               | 8 ++++++++
 libgomp/openacc.f90                                          | 2 ++
 libgomp/openacc_lib.h                                        | 3 +++
 libgomp/testsuite/libgomp.oacc-fortran/openacc_version-1.f   | 9 +++++++++
 libgomp/testsuite/libgomp.oacc-fortran/openacc_version-2.f90 | 9 +++++++++
 12 files changed, 61 insertions(+)
 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/openacc_version-1.f
 create mode 100644 libgomp/testsuite/libgomp.oacc-fortran/openacc_version-2.f90

diff --git gcc/c-family/c-cppbuiltin.c gcc/c-family/c-cppbuiltin.c
index ed4c82c..d48d96f 100644
--- gcc/c-family/c-cppbuiltin.c
+++ gcc/c-family/c-cppbuiltin.c
@@ -895,6 +895,9 @@ c_cpp_builtins (cpp_reader *pfile)
   else if (flag_stack_protect == 1)
     cpp_define (pfile, "__SSP__=1");
 
+  if (flag_openacc)
+    cpp_define (pfile, "_OPENACC=201306");
+
   if (flag_openmp)
     cpp_define (pfile, "_OPENMP=201307");
 
diff --git gcc/fortran/cpp.c gcc/fortran/cpp.c
index ea53681..58f6cc9 100644
--- gcc/fortran/cpp.c
+++ gcc/fortran/cpp.c
@@ -169,6 +169,9 @@ cpp_define_builtins (cpp_reader *pfile)
   cpp_define (pfile, "__GFORTRAN__=1");
   cpp_define (pfile, "_LANGUAGE_FORTRAN=1");
 
+  if (gfc_option.gfc_flag_openacc)
+    cpp_define (pfile, "_OPENACC=201306");
+
   if (gfc_option.gfc_flag_openmp)
     cpp_define (pfile, "_OPENMP=201107");
 
diff --git gcc/testsuite/c-c++-common/cpp/openacc-define-1.c 
gcc/testsuite/c-c++-common/cpp/openacc-define-1.c
index feaf778..cd37548 100644
--- gcc/testsuite/c-c++-common/cpp/openacc-define-1.c
+++ gcc/testsuite/c-c++-common/cpp/openacc-define-1.c
@@ -1,2 +1,6 @@
 /* { dg-do preprocess } */
 /* { dg-require-effective-target fopenacc } */
+
+#ifdef _OPENACC
+# error _OPENACC defined
+#endif
diff --git gcc/testsuite/c-c++-common/cpp/openacc-define-2.c 
gcc/testsuite/c-c++-common/cpp/openacc-define-2.c
index a2f3e28..b007e32 100644
--- gcc/testsuite/c-c++-common/cpp/openacc-define-2.c
+++ gcc/testsuite/c-c++-common/cpp/openacc-define-2.c
@@ -1,3 +1,7 @@
 /* { dg-options "-fno-openacc" } */
 /* { dg-do preprocess } */
 /* { dg-require-effective-target fopenacc } */
+
+#ifdef _OPENACC
+# error _OPENACC defined
+#endif
diff --git gcc/testsuite/c-c++-common/cpp/openacc-define-3.c 
gcc/testsuite/c-c++-common/cpp/openacc-define-3.c
index ce270c3..ccedcd9 100644
--- gcc/testsuite/c-c++-common/cpp/openacc-define-3.c
+++ gcc/testsuite/c-c++-common/cpp/openacc-define-3.c
@@ -1,3 +1,11 @@
 /* { dg-options "-fopenacc" } */
 /* { dg-do preprocess } */
 /* { dg-require-effective-target fopenacc } */
+
+#ifndef _OPENACC
+# error _OPENACC not defined
+#endif
+
+#if _OPENACC != 201306
+# error _OPENACC defined to wrong value
+#endif
diff --git gcc/testsuite/gfortran.dg/openacc-define-1.f90 
gcc/testsuite/gfortran.dg/openacc-define-1.f90
index b961468..42f4073 100644
--- gcc/testsuite/gfortran.dg/openacc-define-1.f90
+++ gcc/testsuite/gfortran.dg/openacc-define-1.f90
@@ -1,3 +1,7 @@
 ! { dg-options "-cpp" }
 ! { dg-do preprocess }
 ! { dg-require-effective-target fopenacc }
+
+#ifdef _OPENACC
+# error _OPENACC defined
+#endif
diff --git gcc/testsuite/gfortran.dg/openacc-define-2.f90 
gcc/testsuite/gfortran.dg/openacc-define-2.f90
index 49b714d..8ad1bd5 100644
--- gcc/testsuite/gfortran.dg/openacc-define-2.f90
+++ gcc/testsuite/gfortran.dg/openacc-define-2.f90
@@ -1,3 +1,7 @@
 ! { dg-options "-cpp -fno-openacc" }
 ! { dg-do preprocess }
 ! { dg-require-effective-target fopenacc }
+
+#ifdef _OPENACC
+# error _OPENACC defined
+#endif
diff --git gcc/testsuite/gfortran.dg/openacc-define-3.f90 
gcc/testsuite/gfortran.dg/openacc-define-3.f90
index 8018d5c..b6c296e 100644
--- gcc/testsuite/gfortran.dg/openacc-define-3.f90
+++ gcc/testsuite/gfortran.dg/openacc-define-3.f90
@@ -1,3 +1,11 @@
 ! { dg-options "-cpp -fopenacc" }
 ! { dg-do preprocess }
 ! { dg-require-effective-target fopenacc }
+
+#ifndef _OPENACC
+# error _OPENACC not defined
+#endif
+
+#if _OPENACC != 201306
+# error _OPENACC defined to wrong value
+#endif
diff --git libgomp/openacc.f90 libgomp/openacc.f90
index 55b79c2..b2a79f6 100644
--- libgomp/openacc.f90
+++ libgomp/openacc.f90
@@ -34,4 +34,6 @@ module openacc
   use openacc_kinds
   implicit none
 
+  integer, parameter :: openacc_version = 201306
+
 end module openacc
diff --git libgomp/openacc_lib.h libgomp/openacc_lib.h
index b2cb679..d19c95c 100644
--- libgomp/openacc_lib.h
+++ libgomp/openacc_lib.h
@@ -24,3 +24,6 @@
 !  a copy of the GCC Runtime Library Exception along with this program;
 !  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 !  <http://www.gnu.org/licenses/>.
+
+      integer openacc_version
+      parameter (openacc_version = 201306)
diff --git libgomp/testsuite/libgomp.oacc-fortran/openacc_version-1.f 
libgomp/testsuite/libgomp.oacc-fortran/openacc_version-1.f
new file mode 100644
index 0000000..db3c6b1
--- /dev/null
+++ libgomp/testsuite/libgomp.oacc-fortran/openacc_version-1.f
@@ -0,0 +1,9 @@
+! { dg-do run }
+
+      program main
+      implicit none
+      include "openacc_lib.h"
+
+      if (openacc_version .ne. 201306) call abort;
+
+      end program main
diff --git libgomp/testsuite/libgomp.oacc-fortran/openacc_version-2.f90 
libgomp/testsuite/libgomp.oacc-fortran/openacc_version-2.f90
new file mode 100644
index 0000000..a14ecdd
--- /dev/null
+++ libgomp/testsuite/libgomp.oacc-fortran/openacc_version-2.f90
@@ -0,0 +1,9 @@
+! { dg-do run }
+
+program main
+  use openacc
+  implicit none
+
+  if (openacc_version .ne. 201306) call abort;
+
+end program main
-- 
1.8.1.1

Reply via email to