From patchwork Sat Jan 8 18:28:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 77972 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 7F3D2B70B3 for ; Sun, 9 Jan 2011 05:28:35 +1100 (EST) Received: (qmail 17916 invoked by alias); 8 Jan 2011 18:28:33 -0000 Received: (qmail 17901 invoked by uid 22791); 8 Jan 2011 18:28:33 -0000 X-SWARE-Spam-Status: No, hits=-0.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST 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; Sat, 08 Jan 2011 18:28:28 +0000 Received: by bwz10 with SMTP id 10so17913653bwz.20 for ; Sat, 08 Jan 2011 10:28:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.101.81 with SMTP id b17mr14045260bko.126.1294511306314; Sat, 08 Jan 2011 10:28:26 -0800 (PST) Received: by 10.204.7.13 with HTTP; Sat, 8 Jan 2011 10:28:26 -0800 (PST) Date: Sat, 8 Jan 2011 19:28:26 +0100 Message-ID: Subject: [Patch, Fortran, OOP] PR 46313: class container naming collisions (once again) 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, I plan to commit the attached patch as obvious, unless anyone objects. It fixes another case of class container naming collisions (comment #12/#19 in the PR). We had fixed a few such cases before, and I hope there are not much more left ... I am in the process of regtesting and will commit tomorrow if no one objects until then. Cheers, Janus 2011-01-08 Janus Weil PR fortran/46313 * class.c (get_unique_type_string): Make type name start with upper case letter. 2011-01-08 Janus Weil PR fortran/46313 * gfortran.dg/class_35.f90: New. Index: gcc/testsuite/gfortran.dg/class_35.f90 =================================================================== --- gcc/testsuite/gfortran.dg/class_35.f90 (revision 0) +++ gcc/testsuite/gfortran.dg/class_35.f90 (revision 0) @@ -0,0 +1,26 @@ +! { dg-do run } +! +! PR 46313: [OOP] class container naming collisions +! +! Contributed by Tobias Burnus + +module one + type two_three + end type +end module + +module one_two + type three + end type +end module + +use one +use one_two +class(two_three), allocatable :: a1 +class(three), allocatable :: a2 + +if (same_type_as(a1,a2)) call abort() + +end + +! { dg-final { cleanup-modules "one one_two" } } Index: gcc/fortran/class.c =================================================================== --- gcc/fortran/class.c (revision 168586) +++ gcc/fortran/class.c (working copy) @@ -116,13 +116,16 @@ gfc_class_null_initializer (gfc_typespec *ts) static void get_unique_type_string (char *string, gfc_symbol *derived) -{ +{ + char dt_name[GFC_MAX_SYMBOL_LEN+1]; + sprintf (dt_name, "%s", derived->name); + dt_name[0] = TOUPPER (dt_name[0]); if (derived->module) - sprintf (string, "%s_%s", derived->module, derived->name); + sprintf (string, "%s_%s", derived->module, dt_name); else if (derived->ns->proc_name) - sprintf (string, "%s_%s", derived->ns->proc_name->name, derived->name); + sprintf (string, "%s_%s", derived->ns->proc_name->name, dt_name); else - sprintf (string, "_%s", derived->name); + sprintf (string, "_%s", dt_name); }