From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D04B3385703C; Wed, 18 Aug 2021 11:09:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D04B3385703C From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/95901] [C, C++] OpenACC, OpenMP executable directives wrongly refused after labels Date: Wed, 18 Aug 2021 11:09:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: openacc, openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Aug 2021 11:09:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95901 --- Comment #3 from Jakub Jelinek --- 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, o= r 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 th= at 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 attribu= te 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.=