aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-04-08 09:39:43 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-04-08 09:39:43 +0200
commit13e41d8b9d3d7598c72c38acc86a3d97046c8373 (patch)
tree90000a02958e8b0e36e120c7afcc9b6e839b4c04 /gcc/c/c-decl.c
parent38c3017f257484a6739e2fba821d95794f7f175c (diff)
downloadgcc-13e41d8b9d3d7598c72c38acc86a3d97046c8373.zip
gcc-13e41d8b9d3d7598c72c38acc86a3d97046c8373.tar.gz
gcc-13e41d8b9d3d7598c72c38acc86a3d97046c8373.tar.bz2
[C/C++, OpenACC] Reject vars of different scope in acc declare (PR94120)
gcc/c/ PR middle-end/94120 * c-decl.c (c_check_in_current_scope): New function. * c-tree.h (c_check_in_current_scope): Declare it. * c-parser.c (c_parser_oacc_declare): Add check that variables are declared in the same scope as the directive. Fix handling of namespace vars. gcc/cp/ PR middle-end/94120 * paser.c (cp_parser_oacc_declare): Add check that variables are declared in the same scope as the directive. gcc/testsuite/ PR middle-end/94120 * c-c++-common/goacc/declare-pr94120.c: New. * g++.dg/declare-pr94120.C: New. libgomp/testsuite/ PR middle-end/94120 * libgomp.oacc-c++/declare-pr94120.C: New.
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index b31d99f..0b7f437 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -12041,4 +12041,12 @@ c_check_omp_declare_reduction_r (tree *tp, int *, void *data)
return NULL_TREE;
}
+
+bool
+c_check_in_current_scope (tree decl)
+{
+ struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (decl));
+ return b != NULL && B_IN_CURRENT_SCOPE (b);
+}
+
#include "gt-c-c-decl.h"