From patchwork Tue Aug 16 17:18:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 110204 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]) by ozlabs.org (Postfix) with SMTP id EC054B6F80 for ; Wed, 17 Aug 2011 03:18:56 +1000 (EST) Received: (qmail 20600 invoked by alias); 16 Aug 2011 17:18:53 -0000 Received: (qmail 20585 invoked by uid 22791); 16 Aug 2011 17:18:52 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-yi0-f47.google.com (HELO mail-yi0-f47.google.com) (209.85.218.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 16 Aug 2011 17:18:38 +0000 Received: by yia28 with SMTP id 28so106239yia.20 for ; Tue, 16 Aug 2011 10:18:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.170.101 with SMTP id o65mr16704992yhl.38.1313515117288; Tue, 16 Aug 2011 10:18:37 -0700 (PDT) Received: by 10.146.82.7 with HTTP; Tue, 16 Aug 2011 10:18:37 -0700 (PDT) Date: Tue, 16 Aug 2011 19:18:37 +0200 Message-ID: Subject: [Patch, Fortran] PR 50070: Segmentation fault at size_binop_loc in fold-const.c From: Janus Weil To: gfortran , gcc-patches 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 Hi all, here is a small patch for an ICE-on-invalid problem with COMMON and character length. I was kinda surprised that we don't catch this already. The fix is rather simple, but after the amount of discussion (that I had with myself) in the PR, I probably cannot claim that it was 'obvious' to me. In any case, the patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk? Cheers, Janus 2011-08-16 Janus Weil PR fortran/50070 * resolve.c (resolve_fl_variable): Reject non-constant character lengths in COMMON variables. 2011-08-16 Janus Weil PR fortran/50070 * gfortran.dg/common_13.f90: New. Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 177779) +++ gcc/fortran/resolve.c (working copy) @@ -10169,15 +10169,22 @@ resolve_fl_variable (gfc_symbol *sym, int mp_flag) if (!gfc_is_constant_expr (e) && !(e->expr_type == EXPR_VARIABLE - && e->symtree->n.sym->attr.flavor == FL_PARAMETER) - && sym->ns->proc_name - && (sym->ns->proc_name->attr.flavor == FL_MODULE - || sym->ns->proc_name->attr.is_main_program) - && !sym->attr.use_assoc) + && e->symtree->n.sym->attr.flavor == FL_PARAMETER)) { - gfc_error ("'%s' at %L must have constant character length " - "in this context", sym->name, &sym->declared_at); - return FAILURE; + if (!sym->attr.use_assoc && sym->ns->proc_name + && (sym->ns->proc_name->attr.flavor == FL_MODULE + || sym->ns->proc_name->attr.is_main_program)) + { + gfc_error ("'%s' at %L must have constant character length " + "in this context", sym->name, &sym->declared_at); + return FAILURE; + } + if (sym->attr.in_common) + { + gfc_error ("COMMON variable '%s' at %L must have constant " + "character length", sym->name, &sym->declared_at); + return FAILURE; + } } }