From: Jakub Jelinek Date: Mon, 11 Nov 2019 20:05:11 +0000 (+0100) Subject: c-parser.c (c_parser_translation_unit): Diagnose declare target without corresponding... X-Git-Tag: misc/cutover-git~1363 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cec95887a274390a45b266622ef15dcb1c2b784;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 8cea3f526560..e3a5120ae98b 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2019-11-11 Jakub Jelinek + + * c-parser.c (c_parser_translation_unit): Diagnose declare target + without corresponding end declare target. + 2019-11-08 Richard Sandiford * 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 ed6a9dd74eed..12deb3e76298 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 23576ec1a5df..81811a41a386 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-11-11 Jakub Jelinek + + * semantics.c (finish_translation_unit): Diagnose declare target + without corresponding end declare target. + 2019-11-10 Jason Merrill Implement D1957R0, T* to bool should be considered narrowing. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8293c0721bd5..0ce73af5bc6e 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 88088fafe6b8..138afb2d5a9c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-11-11 Jakub Jelinek + + * c-c++-common/gomp/declare-target-5.c: New test. + 2019-11-11 Richard Sandiford * 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 000000000000..b52c9f207a22 --- /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'" } */