diff --git a/gcc/gimple.h b/gcc/gimple.h
index 3ec86f5f08283e55d4eefdf0f4d709d1b6c16abf..91b92b4a4d172d595fdd1b26f8a5c317f13775f4 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -6501,6 +6501,14 @@ is_gimple_omp_oacc (const gimple *stmt)
   gcc_assert (is_gimple_omp (stmt));
   switch (gimple_code (stmt))
     {
+    case GIMPLE_OMP_ATOMIC_LOAD:
+    case GIMPLE_OMP_ATOMIC_STORE:
+    case GIMPLE_OMP_CONTINUE:
+    case GIMPLE_OMP_RETURN:
+      /* Codes shared between OpenACC and OpenMP cannot be used to disambiguate
+	 the two.  */
+      gcc_unreachable ();
+
     case GIMPLE_OMP_FOR:
       switch (gimple_omp_for_kind (stmt))
 	{
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index cadca7e201f2c50a3a6ca8ccb77264758eef7aaf..d1136d181b348c68f0539ffaa25f78e47c26069d 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3016,11 +3016,12 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx)
 
   /* No nesting of non-OpenACC STMT (that is, an OpenMP one, or a GOMP builtin)
      inside an OpenACC CTX.  */
-  if (!(is_gimple_omp (stmt)
-	&& is_gimple_omp_oacc (stmt))
-      /* Except for atomic codes that we share with OpenMP.  */
-      && !(gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
-	   || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE))
+  if (gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
+      || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE)
+    /* ..., except for the atomic codes that OpenACC shares with OpenMP.  */
+    ;
+  else if (!(is_gimple_omp (stmt)
+	     && is_gimple_omp_oacc (stmt)))
     {
       if (oacc_get_fn_attrib (cfun->decl) != NULL)
 	{