From 56f71478487174d7bacbe51a9c35d23257db905e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 9 Feb 2017 15:01:44 +0100 Subject: [PATCH] re PR c/79431 (ICE in get, at cgraph.h:397) PR c/79431 * gimplify.c (gimplify_adjust_omp_clauses): Ignore "omp declare target link" attribute unless is_global_var. * omp-offload.c (find_link_var_op): Likewise. c/ * c-parser.c (c_parser_omp_declare_target): Don't invoke symtab_node::get on automatic variables. cp/ * parser.c (cp_parser_oacc_declare): Formatting fix. (cp_parser_omp_declare_target): Don't invoke symtab_node::get on automatic variables. testsuite/ * c-c++-common/gomp/pr79431.c: New test. From-SVN: r245302 --- gcc/ChangeLog | 7 +++++++ gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 5 ++++- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/parser.c | 7 +++++-- gcc/gimplify.c | 5 +++-- gcc/omp-offload.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/gomp/pr79431.c | 8 ++++++++ 9 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/gomp/pr79431.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7228afcbc6f..184e7d1b48e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-02-09 Jakub Jelinek + + PR c/79431 + * gimplify.c (gimplify_adjust_omp_clauses): Ignore + "omp declare target link" attribute unless is_global_var. + * omp-offload.c (find_link_var_op): Likewise. + 2017-02-09 Nathan Sidwell Chung-Lin Tang diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c05721df7ec..98f7c4ce489 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2017-02-09 Jakub Jelinek + + PR c/79431 + * c-parser.c (c_parser_omp_declare_target): Don't invoke + symtab_node::get on automatic variables. + 2016-02-09 Nathan Sidwell Chung-Lin Tang diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 6e83728b577..8f4f569bd4a 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -16849,8 +16849,11 @@ c_parser_omp_declare_target (c_parser *parser) } if (!at1) { - symtab_node *node = symtab_node::get (t); DECL_ATTRIBUTES (t) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t)); + if (TREE_CODE (t) != FUNCTION_DECL && !is_global_var (t)) + continue; + + symtab_node *node = symtab_node::get (t); if (node != NULL) { node->offloadable = 1; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 291dcddcde1..a71cca1d20b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2017-02-09 Jakub Jelinek + + PR c/79431 + * parser.c (cp_parser_oacc_declare): Formatting fix. + (cp_parser_omp_declare_target): Don't invoke symtab_node::get on + automatic variables. + 2016-02-09 Nathan Sidwell Chung-Lin Tang diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 41b08e1a7a3..b46ee7c9454 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -36230,7 +36230,7 @@ cp_parser_oacc_declare (cp_parser *parser, cp_token *pragma_tok) id = get_identifier ("omp declare target"); DECL_ATTRIBUTES (decl) - = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl)); + = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl)); if (global_bindings_p ()) { symtab_node *node = symtab_node::get (decl); @@ -36770,8 +36770,11 @@ cp_parser_omp_declare_target (cp_parser *parser, cp_token *pragma_tok) } if (!at1) { - symtab_node *node = symtab_node::get (t); DECL_ATTRIBUTES (t) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t)); + if (TREE_CODE (t) != FUNCTION_DECL && !is_global_var (t)) + continue; + + symtab_node *node = symtab_node::get (t); if (node != NULL) { node->offloadable = 1; diff --git a/gcc/gimplify.c b/gcc/gimplify.c index dd73fc258e5..1b9c8d23f1a 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8938,8 +8938,9 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p, if ((ctx->region_type & ORT_TARGET) != 0 && !(n->value & GOVD_SEEN) && GOMP_MAP_ALWAYS_P (OMP_CLAUSE_MAP_KIND (c)) == 0 - && !lookup_attribute ("omp declare target link", - DECL_ATTRIBUTES (decl))) + && (!is_global_var (decl) + || !lookup_attribute ("omp declare target link", + DECL_ATTRIBUTES (decl)))) { remove = true; /* For struct element mapping, if struct is never referenced diff --git a/gcc/omp-offload.c b/gcc/omp-offload.c index e4ce48cb8e5..6fbe4ff753a 100644 --- a/gcc/omp-offload.c +++ b/gcc/omp-offload.c @@ -1819,7 +1819,9 @@ find_link_var_op (tree *tp, int *walk_subtrees, void *) { tree t = *tp; - if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t) + if (VAR_P (t) + && DECL_HAS_VALUE_EXPR_P (t) + && is_global_var (t) && lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (t))) { *walk_subtrees = 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95c0bfc5c7e..18a7a08d2c8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-02-09 Jakub Jelinek + + PR c/79431 + * c-c++-common/gomp/pr79431.c: New test. + 2017-02-09 Nathan Sidwell Cesar Philippidis Joseph Myers diff --git a/gcc/testsuite/c-c++-common/gomp/pr79431.c b/gcc/testsuite/c-c++-common/gomp/pr79431.c new file mode 100644 index 00000000000..62f7a059a74 --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr79431.c @@ -0,0 +1,8 @@ +/* PR c/79431 */ + +void +foo (void) +{ + int a; + #pragma omp declare target (a) +} -- 2.30.2