From patchwork Sun Jan 6 15:32:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 209777 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 88E242C0084 for ; Mon, 7 Jan 2013 02:32:52 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1358091173; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=PsTPuHD EiRHLN5HQNOqoblEezaA=; b=dPuZX/WrjXGCvWN7U9hgvz0/mpfUIoQzcWGbeVA wORtYHu1UU70L3/46SUlsh71ty9Clw6EbXtkfF2AI1Qdugx/eur2ivnF0fSXfdc4 OANjGiKew1WJb0H25ck7F1pzSqgOWPvs4uXXFUOUlDkO8BGXASWMOYbVacnUDr0c AyCs= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=GLhRZncLiiCrTF0QyDZgvd6XloCYnGltbPFyyx3NLW7NUcteHG8Er4N/ZQmeoy h+vehckmwf3nMzHw+HfI3x4cVqaaEx6+rdeuaRxiPJFUQ74AXiqecQ5xr9G3asjD GaW8QILD2jKB82euq/bMx2iQ6ZRziWD3sh8fdl7Yj5rBM=; Received: (qmail 26955 invoked by alias); 6 Jan 2013 15:32:44 -0000 Received: (qmail 26939 invoked by uid 22791); 6 Jan 2013 15:32:43 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_FC X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 Jan 2013 15:32:35 +0000 Received: from archimedes.net-b.de (port-92-195-50-179.dynamic.qsc.de [92.195.50.179]) by mx02.qsc.de (Postfix) with ESMTP id DD41B2487D; Sun, 6 Jan 2013 16:32:33 +0100 (CET) Message-ID: <50E99911.1030605@net-b.de> Date: Sun, 06 Jan 2013 16:32:33 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [Patch, Fortran] PR55763 - reject "type is(INTEGER)" with non-class(*) selector in SELECT TYPE 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 A rather obvious fix, though one can think about the error wording. Bootstrapped and regtested on x86-64-gnu-linux. OK for the trunk? Tobias 2012-01-06 Tobias Burnus PR fortran/55763 * resolve.c (resolve_select_type): Reject intrinsic types for a non-unlimited-polymorphic selector. 2012-01-06 Tobias Burnus PR fortran/55763 * gfortran.dg/select_type_32.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 54ac3c6..a3f0485 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -8388,12 +8388,16 @@ resolve_select_type (gfc_code *code, gfc_namespace *old_ns) } /* Check F03:C816. */ - if ((c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS) - && !selector_type->attr.unlimited_polymorphic - && !gfc_type_is_extension_of (selector_type, c->ts.u.derived)) + if (c->ts.type != BT_UNKNOWN && !selector_type->attr.unlimited_polymorphic + && ((c->ts.type != BT_DERIVED && c->ts.type != BT_CLASS) + || !gfc_type_is_extension_of (selector_type, c->ts.u.derived))) { - gfc_error ("Derived type '%s' at %L must be an extension of '%s'", - c->ts.u.derived->name, &c->where, selector_type->name); + if (c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS) + gfc_error ("Derived type '%s' at %L must be an extension of '%s'", + c->ts.u.derived->name, &c->where, selector_type->name); + else + gfc_error ("Unexpected intrinsic type '%s' at %L", + gfc_basic_typename (c->ts.type), &c->where); error++; continue; } diff --git a/gcc/testsuite/gfortran.dg/select_type_32.f90 b/gcc/testsuite/gfortran.dg/select_type_32.f90 new file mode 100644 index 0000000..5e36639 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_type_32.f90 @@ -0,0 +1,25 @@ +! { dg-do compile } +! +! PR fortran/55763 +! +! Contributed by Harald Anlauf +! + +module gfcbug122 + implicit none + type myobj + class(*), allocatable :: x + contains + procedure :: print + end type myobj +contains + subroutine print(this) + class(myobj) :: this + select type (this) + type is (integer) ! { dg-error "Unexpected intrinsic type 'INTEGER'" } + type is (real) ! { dg-error "Unexpected intrinsic type 'REAL'" } + type is (complex) ! { dg-error "Unexpected intrinsic type 'COMPLEX'" } + type is (character(len=*)) ! { dg-error "Unexpected intrinsic type 'CHARACTER'" } + end select + end subroutine print +end module gfcbug122