Hi! ../../map.c: In function 'main': ../../map.c:4:21: error: array type has incomplete element type extern struct foo s2[1]; ^ ../../map.c:8:11: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in c_finish_omp_clauses, at c/c-typeck.c:12126 #pragma omp target map(s2) /* { dg-error "array type has incomplete element type" } */ ^ 0xe5cf3a tree_class_check_failed(tree_node const*, tree_code_class, char const*, int, char const*) ../../source/gcc/tree.c:9271 0x580866 tree_class_check ../../source/gcc/tree.h:2894 0x580866 c_finish_omp_clauses(tree_node*) ../../source/gcc/c/c-typeck.c:12126 0x59f99b c_parser_omp_all_clauses ../../source/gcc/c/c-parser.c:11367 0x5ad404 c_parser_omp_target ../../source/gcc/c/c-parser.c:13081 [...]
This does not happen for C++, because gcc/cp/decl2.c:cp_omp_mappable_type catches the »type == error_mark_node« case -- so I suggest to do the same generically/for C. OK to commit the following to trunk, once tested? commit 63aa927ea54304f6bfd119ad7f72a0322e059637 Author: Thomas Schwinge <tho...@codesourcery.com> Date: Wed Mar 5 17:06:50 2014 +0100 The error_mark_node is not an OpenMP mappable type. gcc/ * langhooks.c (lhd_omp_mappable_type): The error_mark_node is not an OpenMP mappable type. gcc/c/ * c-decl.c (c_decl_attributes): Use lang_hooks.types.omp_mappable_type. * c-typeck.c (c_finish_omp_clauses): Likewise. gcc/testsuite/ * c-c++-common/gomp/map-1.c: Extend. diff --git gcc/c/c-decl.c gcc/c/c-decl.c index 7a7d68e..2c41bf2 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -4024,7 +4024,7 @@ c_decl_attributes (tree *node, tree attributes, int flags) error ("%q+D in block scope inside of declare target directive", *node); else if (TREE_CODE (*node) == VAR_DECL - && !COMPLETE_TYPE_P (TREE_TYPE (*node))) + && !lang_hooks.types.omp_mappable_type (TREE_TYPE (*node))) error ("%q+D in declare target directive does not have mappable type", *node); else diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c index 191adfb..65ef1f3 100644 --- gcc/c/c-typeck.c +++ gcc/c/c-typeck.c @@ -12082,7 +12082,7 @@ c_finish_omp_clauses (tree clauses) else { t = OMP_CLAUSE_DECL (c); - if (!COMPLETE_TYPE_P (TREE_TYPE (t))) + if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "array section does not have mappable type " @@ -12111,9 +12111,9 @@ c_finish_omp_clauses (tree clauses) } else if (!c_mark_addressable (t)) remove = true; - else if (!COMPLETE_TYPE_P (TREE_TYPE (t)) - && !(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP - && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER)) + else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP + && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER) + && !lang_hooks.types.omp_mappable_type (TREE_TYPE (t))) { error_at (OMP_CLAUSE_LOCATION (c), "%qD does not have a mappable type in %qs clause", t, diff --git gcc/langhooks.c gcc/langhooks.c index eca0299..d00ebd8 100644 --- gcc/langhooks.c +++ gcc/langhooks.c @@ -524,13 +524,15 @@ lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED, { } -/* Return true if TYPE is an OpenMP mappable type. By default return true - if type is complete. */ +/* Return true if TYPE is an OpenMP mappable type. */ bool lhd_omp_mappable_type (tree type) { - return COMPLETE_TYPE_P (type); + /* Mappable type has to be complete. */ + if (type == error_mark_node || !COMPLETE_TYPE_P (type)) + return false; + return true; } /* Common function for add_builtin_function and diff --git gcc/testsuite/c-c++-common/gomp/map-1.c gcc/testsuite/c-c++-common/gomp/map-1.c index 694d88c..5dad7d6 100644 --- gcc/testsuite/c-c++-common/gomp/map-1.c +++ gcc/testsuite/c-c++-common/gomp/map-1.c @@ -8,6 +8,8 @@ int k[10], l[10], m[10], n[10], o; int *p; int **q; int r[4][4][4][4][4]; +extern struct s s1; +extern struct s s2[1]; /* { dg-error "array type has incomplete element type" "" { target c } } */ int t[10]; #pragma omp threadprivate (t) #pragma omp declare target @@ -32,6 +34,10 @@ foo (int g[3][10], int h[4][8], int i[2][10], int j[][9], ; #pragma omp target map(to: o[2:5]) /* { dg-error "does not have pointer or array type" } */ ; + #pragma omp target map(alloc: s1) /* { dg-error "'s1' does not have a mappable type in 'map' clause" } */ + ; + #pragma omp target map(alloc: s2) /* { dg-error "'s2' does not have a mappable type in 'map' clause" } */ + ; #pragma omp target map(to: a[:][:]) /* { dg-error "array type length expression must be specified" } */ bar (&a[0][0]); /* { dg-error "referenced in target region does not have a mappable type" } */ #pragma omp target map(tofrom: b[-1:]) /* { dg-error "negative low bound in array section" } */ Grüße, Thomas
pgpwNLhvx_O8P.pgp
Description: PGP signature