public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95901] New: [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels
@ 2020-06-25 20:40 tschwinge at gcc dot gnu.org
  2021-08-18 10:58 ` [Bug c/95901] " tschwinge at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2020-06-25 20:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95901

            Bug ID: 95901
           Summary: [C, C++] OpenACC, OpenMP executable directives wrongly
                    refused after labels
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: openacc, openmp
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Created attachment 48785
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48785&action=edit
'pr.c'

..., or am I confused?  (It's late.)

      switch (argc)
        {
        case 4:
    #pragma acc update self(argc) // { dg-bogus "may only be used in compound
statements" }
          break;

Etc., see attached 'pr.c'

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/95901] [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels
  2020-06-25 20:40 [Bug c/95901] New: [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels tschwinge at gcc dot gnu.org
@ 2021-08-18 10:58 ` tschwinge at gcc dot gnu.org
  2021-08-18 10:58 ` tschwinge at gcc dot gnu.org
  2021-08-18 11:09 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2021-08-18 10:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95901

Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-8-18

--- Comment #1 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
For the record, the recentish commit 8b7a9a249a63e066cff6e95db05a3158b4cc56cc
"C Parser: Implement mixing of labels and code" gets us rid of the following C
vs. C++ difference:

    @@ -17,16 +17,18 @@
     pr.c:21:9: error: ‘#pragma omp target enter data’ may only be used in
compound statements
        21 | #pragma omp target enter data map(to:argc) // { dg-bogus "may only
be used in compound statements" }
           |         ^~~
    -pr.c:20:10: error: label at end of compound statement
    -   20 |     case 100: // { dg-bogus "label at end of compound statement" }
    -      |          ^~~
     pr.c:26:9: error: ‘#pragma omp target exit data’ may only be used in
compound statements
        26 | #pragma omp target exit data map(from:argc) // { dg-bogus "may
only be used in compound statements" }
           |         ^~~
    -pr.c:25:2: error: label at end of compound statement
    -   25 |  l1: // { dg-bogus "label at end of compound statement" }
    -      |  ^~

Meaning: no more 'error: label at end of compound statement' diagnostics for C,
as already the case for C++.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/95901] [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels
  2020-06-25 20:40 [Bug c/95901] New: [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels tschwinge at gcc dot gnu.org
  2021-08-18 10:58 ` [Bug c/95901] " tschwinge at gcc dot gnu.org
@ 2021-08-18 10:58 ` tschwinge at gcc dot gnu.org
  2021-08-18 11:09 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2021-08-18 10:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95901

--- Comment #2 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
For the record, the recent commit 1bf976a5de69ecd9b1e10eb7515357b98e78faf7
"openmp: Actually ignore pragma_stmt pragmas for which c_parser_pragma returns
false" gets us rid of the following C vs. C++ difference:

    @@ -17,9 +17,15 @@
     pr.c:21:9: error: ‘#pragma omp target enter data’ may only be used in
compound statements
        21 | #pragma omp target enter data map(to:argc) // { dg-bogus "may only
be used in compound statements" }
           |         ^~~
    +pr.c:23:5: error: expected primary-expression before ‘}’ token
    +   23 |     }
    +      |     ^
     pr.c:26:9: error: ‘#pragma omp target exit data’ may only be used in
compound statements
        26 | #pragma omp target exit data map(from:argc) // { dg-bogus "may
only be used in compound statements" }
           |         ^~~
    +pr.c:27:1: error: expected primary-expression before ‘}’ token
    +   27 | }
    +      | ^
     pr.c:25:2: warning: label ‘l1’ defined but not used [-Wunused-label]
        25 |  l1: // { dg-bogus "label at end of compound statement" }
           |  ^~

Meaning: no more 'error: expected primary-expression before ‘}’ token'
diagnostics for C++, as already the case for C.


(But that commit does not otherwise address this issue.)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/95901] [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels
  2020-06-25 20:40 [Bug c/95901] New: [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels tschwinge at gcc dot gnu.org
  2021-08-18 10:58 ` [Bug c/95901] " tschwinge at gcc dot gnu.org
  2021-08-18 10:58 ` tschwinge at gcc dot gnu.org
@ 2021-08-18 11:09 ` jakub at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-08-18 11:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95901

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
For OpenMP, we have the C:
A stand-alone directive may not be used in place of a substatement in a
selection statement, in place of the loop body in an iteration statement, or in
place of the statement that follows a label.
and C++:
A stand-alone directive may not be used in place of a substatement in a
selection statement or iteration statement, or in place of the statement that
follows a label.
restrictions (5.1 wording) and in 5.1+ also similar restriction about
declarative directives instead of stand-alone.
So, #pragma omp barrier etc. aren't allowed in that spot.
The rationale is to avoid different parsing between ignoring the pragmas and
when honoring them, case 4: } is invalid, or in if (cond) foo (); foo () is the
if then body, but if stand-alone pragmas would be allowed there,
case 4:
#pragma omp barrier
}
would be valid and
if (cond)
#pragma omp barrier
foo ();
would have foo (); parsed as unconditional after the if.

Now, the above mentioned restrictions don't make much sense for the attribute
syntax, I'll try to make them specific to pragma syntax.  And, while for
most of the declarative directives the restrictions make sense for pragma
syntax
(e.g. declare reduction, declare target, declare mapper), for declare simd and
declare variant they actually need a following declaration and C++ allows
if (cond)
  extern int foo ();
while C doesn't and so in theory
if (cond)
  #pragma omp declare simd
  extern int foo ();
could be allowed in C++ and not allowed in C.

What exactly OpenACC says, I don't know.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-18 11:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 20:40 [Bug c/95901] New: [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels tschwinge at gcc dot gnu.org
2021-08-18 10:58 ` [Bug c/95901] " tschwinge at gcc dot gnu.org
2021-08-18 10:58 ` tschwinge at gcc dot gnu.org
2021-08-18 11:09 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).