From patchwork Sun Oct 31 10:54:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 69703 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 D42A4B70E7 for ; Sun, 31 Oct 2010 21:55:01 +1100 (EST) Received: (qmail 28806 invoked by alias); 31 Oct 2010 10:54:56 -0000 Received: (qmail 28790 invoked by uid 22791); 31 Oct 2010 10:54:55 -0000 X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-bw0-f47.google.com (HELO mail-bw0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 31 Oct 2010 10:54:50 +0000 Received: by bwz10 with SMTP id 10so3864178bwz.20 for ; Sun, 31 Oct 2010 03:54:48 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.27.20 with SMTP id g20mr5133264bkc.114.1288522488012; Sun, 31 Oct 2010 03:54:48 -0700 (PDT) Received: by 10.204.7.80 with HTTP; Sun, 31 Oct 2010 03:54:47 -0700 (PDT) In-Reply-To: <20101031033259.GA44499@troutmask.apl.washington.edu> References: <20101031033259.GA44499@troutmask.apl.washington.edu> Date: Sun, 31 Oct 2010 11:54:47 +0100 Message-ID: Subject: Re: [PATCH] PR fortran/46152 -- fix namespace pollution in type-spec matching From: Janus Weil To: Steve Kargl Cc: fortran , 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 Steve, > See the PR for a thorough discussion of the problem and > the fix.  The attached patch has been tested on i686-*-freebsd > without regression.  I plan to commit this within the next > 24 hours. I think your patch is basically ok, so thanks for your work! Just one little nit: I still don't quite like the fact that you simply remove the one line in allocate_derived_1 where the error message has changed. What do you think about adding the following hunk in match.c to improve the error message for this case: @@ -2874,7 +2861,15 @@ gfc_match_allocate (void) if (m == MATCH_ERROR) goto cleanup; else if (m == MATCH_NO) - ts.type = BT_UNKNOWN; + { + char name[GFC_MAX_SYMBOL_LEN + 1]; + if (gfc_match ("%n :: ", name) == MATCH_YES) + { + gfc_error ("Error in type-spec at %L", &old_locus); + goto cleanup; + } + ts.type = BT_UNKNOWN; + } else { if (gfc_match (" :: ") == MATCH_YES) so that the test case becomes: I think this would be much better than complaining about something being wrong with the allocate-object, since the colons indicate that the (optional) type-spec is present, so we might as well make use of this information. With this change the patch is ok from my side. Cheers, Janus > 2010-10-30  Steven G. Kargl   > >        PR fortran/46152 >        * gfortran.dg/select_type_11.f03: Update dg-error phrase. >        * gfortran.dg/allocate_with_typespec_4.f90: New test. >        * gfortran.dg/allocate_with_typespec_1.f90: New test. >        * gfortran.dg/allocate_with_typespec_2.f: New test. >        * gfortran.dg/allocate_with_typespec_3.f90: New test. >        * gfortran.dg/allocate_derived_1.f90: Delete an obselescent test. >        * gfortran.dg/select_type_1.f03: Update dg-error phrase. > > 2010-10-30  Steven G. Kargl   > >        PR fortran/46152 >        * fortran/match.c (match_derived_type_spec): Reoplace gfc_match_symbol >        with a gfc_find_symbol to prevent namespace pollution.  Remove dead >        code. >        (match_type_spec): Remove parsing of '::'.  Collapse character >        kind checking to one location. >        (gfc_match_allocate): Use correct locus in error message. > > -- > Steve > Index: gcc/testsuite/gfortran.dg/allocate_derived_1.f90 =================================================================== --- gcc/testsuite/gfortran.dg/allocate_derived_1.f90 (revision 166088) +++ gcc/testsuite/gfortran.dg/allocate_derived_1.f90 (working copy) @@ -32,7 +32,7 @@ allocate(t1 :: x(2)) allocate(t2 :: x(3)) allocate(t3 :: x(4)) - allocate(tx :: x(5)) ! { dg-error "is not an accessible derived type" } + allocate(tx :: x(5)) ! { dg-error "Error in type-spec" } allocate(u0 :: x(6)) ! { dg-error "may not be ABSTRACT" } allocate(v1 :: x(7)) ! { dg-error "is type incompatible with typespec" }