From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75275 invoked by alias); 27 Apr 2017 22:04:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 75158 invoked by uid 89); 27 Apr 2017 22:04:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=encountered, expecting X-Spam-User: qpsmtpd, 2 recipients X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 27 Apr 2017 22:04:17 +0000 Received: from svr-orw-mbx-04.mgc.mentorg.com ([147.34.90.204]) by relay1.mentorg.com with esmtp id 1d3rWL-0005BJ-70 from Cesar_Philippidis@mentor.com ; Thu, 27 Apr 2017 15:04:17 -0700 Received: from [127.0.0.1] (147.34.91.1) by SVR-ORW-MBX-04.mgc.mentorg.com (147.34.90.204) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 27 Apr 2017 15:04:14 -0700 From: Cesar Philippidis Subject: [gomp4] Fix an ICE involving OpenACC routines inside broken fortran functions. To: "gcc-patches@gcc.gnu.org" , Fortran List Message-ID: <305d82b4-08de-fed7-b4f4-ec1c059e0ad3@codesourcery.com> Date: Thu, 27 Apr 2017 22:54:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BEA790B9AE7C0D3C758F1004" X-ClientProxiedBy: svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) To SVR-ORW-MBX-04.mgc.mentorg.com (147.34.90.204) X-SW-Source: 2017-04/txt/msg01438.txt.bz2 --------------BEA790B9AE7C0D3C758F1004 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-length: 645 I encountered an ICE when the fortran FE tries to parse an OpenACC routine directive when the containing function has a syntax error. E.g. integer function f1 is missing an argument list, so the fortran FE will not create a function symbol for f1. Consequently, the OpenACC routine parser cannot register the routine directive with any function, so it hit a gcc_unreachable. This patch replaces that gcc_unreachable with a match_error. While the syntax of the routine directive may be correct, it is still an error to have a dangling acc routine directive not associated with a function. I've applied this patch to gomp-4_0-branch. Cesar --------------BEA790B9AE7C0D3C758F1004 Content-Type: text/x-patch; name="gomp4-broken-routine-ice.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gomp4-broken-routine-ice.diff" Content-length: 1234 2017-04-27 Cesar Philippidis gcc/fortran/ * openmp.c (gfc_match_oacc_routine): Don't match OpenACC routines when the current function failed to parse due to a syntax error. gcc/testsuite/ * gfortran.dg/goacc/routine-10.f90: New test. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 0aecda4..72c6669 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -2576,7 +2576,9 @@ gfc_match_oacc_routine (void) goto cleanup; } else - gcc_unreachable (); + /* Something has gone wrong. Perhaps there was a syntax error + in the program-stmt. */ + goto cleanup; if (n) n->clauses = c; diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-10.f90 b/gcc/testsuite/gfortran.dg/goacc/routine-10.f90 new file mode 100644 index 0000000..4d8b5ba --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/routine-10.f90 @@ -0,0 +1,8 @@ +! Ensure that GFortran doesn't ICE with incomplete function +! definitions. + +! { dg-do compile } + +integer function f1 ! { dg-error "Expected formal argument list in function definition" } + !$acc routine ! { dg-error "Unclassifiable OpenACC directive" } +end function f1 ! { dg-error "Expecting END PROGRAM statement" } --------------BEA790B9AE7C0D3C758F1004--