aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-11-11 21:05:11 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-11-11 21:05:11 +0100
commit7cec95887a274390a45b266622ef15dcb1c2b784 (patch)
tree4932e3a7837baa63bceafca64a2e7c5a382be778
parent599bd99078439b9f11cb271aa919844318381ec5 (diff)
downloadgcc-7cec95887a274390a45b266622ef15dcb1c2b784.zip
gcc-7cec95887a274390a45b266622ef15dcb1c2b784.tar.gz
gcc-7cec95887a274390a45b266622ef15dcb1c2b784.tar.bz2
c-parser.c (c_parser_translation_unit): Diagnose declare target without corresponding end declare target.
* c-parser.c (c_parser_translation_unit): Diagnose declare target without corresponding end declare target. * semantics.c (finish_translation_unit): Diagnose declare target without corresponding end declare target. * c-c++-common/gomp/declare-target-5.c: New test. From-SVN: r278065
-rw-r--r--gcc/c/ChangeLog5
-rw-r--r--gcc/c/c-parser.c8
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/semantics.c8
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/gomp/declare-target-5.c2
6 files changed, 32 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 8cea3f5..e3a5120 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-11 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.c (c_parser_translation_unit): Diagnose declare target
+ without corresponding end declare target.
+
2019-11-08 Richard Sandiford <richard.sandiford@arm.com>
* c-convert.c (convert): Only handle vector conversions if one of
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index ed6a9dd..12deb3e 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1554,6 +1554,14 @@ c_parser_translation_unit (c_parser *parser)
FOR_EACH_VEC_ELT (incomplete_record_decls, i, decl)
if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node)
error ("storage size of %q+D isn%'t known", decl);
+
+ if (current_omp_declare_target_attribute)
+ {
+ if (!errorcount)
+ error ("%<#pragma omp declare target%> without corresponding "
+ "%<#pragma omp end declare target%>");
+ current_omp_declare_target_attribute = 0;
+ }
}
/* Parse an external declaration (C90 6.7, C99 6.9, C11 6.9).
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 23576ec..81811a4 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-11 Jakub Jelinek <jakub@redhat.com>
+
+ * semantics.c (finish_translation_unit): Diagnose declare target
+ without corresponding end declare target.
+
2019-11-10 Jason Merrill <jason@redhat.com>
Implement D1957R0, T* to bool should be considered narrowing.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 8293c07..0ce73af 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3048,6 +3048,14 @@ finish_translation_unit (void)
/* Do file scope __FUNCTION__ et al. */
finish_fname_decls ();
+
+ if (scope_chain->omp_declare_target_attribute)
+ {
+ if (!errorcount)
+ error ("%<#pragma omp declare target%> without corresponding "
+ "%<#pragma omp end declare target%>");
+ scope_chain->omp_declare_target_attribute = 0;
+ }
}
/* Finish a template type parameter, specified as AGGR IDENTIFIER.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 88088fa..138afb2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-11-11 Jakub Jelinek <jakub@redhat.com>
+
+ * c-c++-common/gomp/declare-target-5.c: New test.
+
2019-11-11 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/vect/pr92420.c: New test.
diff --git a/gcc/testsuite/c-c++-common/gomp/declare-target-5.c b/gcc/testsuite/c-c++-common/gomp/declare-target-5.c
new file mode 100644
index 0000000..b52c9f2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/declare-target-5.c
@@ -0,0 +1,2 @@
+#pragma omp declare target
+void foo (void); /* { dg-error "'#pragma omp declare target' without corresponding '#pragma omp end declare target'" } */