This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/45044] Different named COMMON block size: No warning
- From: "burnus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 30 Aug 2011 13:26:23 +0000
- Subject: [Bug fortran/45044] Different named COMMON block size: No warning
- Auto-submitted: auto-generated
- References: <bug-45044-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45044
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 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);