From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11794 invoked by alias); 30 Aug 2011 13:27:05 -0000 Received: (qmail 11785 invoked by uid 22791); 30 Aug 2011 13:27:04 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Aug 2011 13:26:51 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/45044] Different named COMMON block size: No warning Date: Tue, 30 Aug 2011 13:28:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: accepts-invalid, diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg02398.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45044 --- Comment #3 from Tobias Burnus 2011-08-30 13:26:23 UTC --- Simple patch to print also a warning if a smaller named common block follows a larger one. TODO: Print the location of the other COMMON block. One can recover the line number via DECL_SOURCE_FILE and DECL_SOURCE_LINE, but one still lacks the column and the source-line string (cf. gfc_linebuf). --- a/gcc/fortran/trans-common.c +++ b/gcc/fortran/trans-common.c @@ -392,4 +392,10 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init) tree size = TYPE_SIZE_UNIT (union_type); + + if (!tree_int_cst_equal (DECL_SIZE_UNIT (decl), size) + && strcmp (com->name, BLANK_COMMON_NAME)) + gfc_warning ("Named COMMON block '%s' at %L shall be of the " + "same size", com->name, &com->where); + if (tree_int_cst_lt (DECL_SIZE_UNIT (decl), size)) - { + { /* Named common blocks of the same name shall be of the same size @@ -397,5 +403,2 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init) blank common blocks may be of different sizes. */ - if (strcmp (com->name, BLANK_COMMON_NAME)) - gfc_warning ("Named COMMON block '%s' at %L shall be of the " - "same size", com->name, &com->where); DECL_SIZE (decl) = TYPE_SIZE (union_type);