From patchwork Fri Jul 22 18:55:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Kargl X-Patchwork-Id: 651724 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rx0Gx4rGnz9sC4 for ; Sat, 23 Jul 2016 04:56:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=gKk4ij58; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=rav/wrZe925LbEo6Ssp+oeihSgsoC6sGjHipnFxx3r3 1mjVO1Z/CHeIZNX+UC8oHI0oZCnY20KrqCrl7wkJp9rCCadpBXLuRvXiftfgAmrU MTY2a80RPiodyLo/qoVRmvFRCpJ3v31K+EDfDPhQetHGFT+3gNcFltNtCWQTz/7w = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=OFt/prFegv2Un4SBRU5VjaIHAPs=; b=gKk4ij58SFh5d8lTd GuMtc9S68+0Q+VGfPuIRWKJSjEoftnd4i5jQb4Ce4SNHqmekmhhiTw/IgvAfXUig zKgwVXZEiQi8YYrL3PtvALLwGFV5sWvQef9v73dwzgPai6WKnbcmyPkYIW6Jplhe 62eTENqVppX9yjnyqsbYc3NNzM= Received: (qmail 84284 invoked by alias); 22 Jul 2016 18:55:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 84264 invoked by uid 89); 22 Jul 2016 18:55:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=UD:u.cl, UD:ts.u.cl, tsucl, ts.u.cl X-Spam-User: qpsmtpd, 2 recipients X-HELO: troutmask.apl.washington.edu Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 22 Jul 2016 18:55:44 +0000 Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id u6MItgV9034693 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 22 Jul 2016 11:55:42 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id u6MItgau034692; Fri, 22 Jul 2016 11:55:42 -0700 (PDT) (envelope-from sgk) Date: Fri, 22 Jul 2016 11:55:42 -0700 From: Steve Kargl To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [Committed] PR fortran/71935 Message-ID: <20160722185542.GA34646@troutmask.apl.washington.edu> Reply-To: kargl@uw.edu MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) I've committed the following patch under "obviously correct." 2016-07-22 Steven G. Kargl PR fortran/71935 * check.c (is_c_interoperable): Simplify right expression. 2016-07-22 Steven G. Kargl PR fortran/71935 * gfortran.dg/c_sizeof_1.f90: Move invalid code to ... * gfortran.dg/c_sizeof_6.f90: here. Test for error. * gfortran.dg/pr71935.f90: New test. Index: gcc/fortran/check.c =================================================================== --- gcc/fortran/check.c (revision 238660) +++ gcc/fortran/check.c (working copy) @@ -4278,7 +4278,7 @@ is_c_interoperable (gfc_expr *expr, cons } if (expr->ts.u.cl && expr->ts.u.cl->length - && !gfc_simplify_expr (expr, 0)) + && !gfc_simplify_expr (expr->ts.u.cl->length, 0)) gfc_internal_error ("is_c_interoperable(): gfc_simplify_expr failed"); if (!c_loc && expr->ts.u.cl Index: gcc/testsuite/gfortran.dg/c_sizeof_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/c_sizeof_1.f90 (revision 238660) +++ gcc/testsuite/gfortran.dg/c_sizeof_1.f90 (working copy) @@ -22,9 +22,6 @@ if (i /= 4) call abort() i = c_sizeof(str2(1)) if (i /= 1) call abort() -i = c_sizeof(str2(1:3)) -if (i /= 3) call abort() - write(*,*) c_sizeof(cptr), c_sizeof(iptr), c_sizeof(C_NULL_PTR) ! Using GNU's SIZEOF Index: gcc/testsuite/gfortran.dg/c_sizeof_6.f90 =================================================================== --- gcc/testsuite/gfortran.dg/c_sizeof_6.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/c_sizeof_6.f90 (working copy) @@ -0,0 +1,16 @@ +! { dg-do compile } +! +program foo + + use iso_c_binding, only: c_int, c_char, c_sizeof + + integer(kind=c_int) :: i + + character(kind=c_char,len=1),parameter :: str2(4) = ["a","b","c","d"] + + i = c_sizeof(str2(1:3)) ! { dg-error "must be an interoperable data" } + + if (i /= 3) call abort() + +end program foo + Index: gcc/testsuite/gfortran.dg/pr71935.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr71935.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr71935.f90 (working copy) @@ -0,0 +1,7 @@ +! { dg-do compile } +program p + use iso_c_binding + character(len=1, kind=c_char), parameter :: z(2) = 'z' + print *, sizeof(z(3)) ! { dg-error "is out of bounds" } + print *, c_sizeof(z(3)) ! { dg-error "is out of bounds" } +end