aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-common.c
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2011-08-31 00:09:49 +0200
committerTobias Burnus <burnus@gcc.gnu.org>2011-08-31 00:09:49 +0200
commitdc8c7978e0cab480de3f932d1cb76d7bf5e72816 (patch)
tree3e7fe5122b787633b75f5d77bf9700191e3e9c7e /gcc/fortran/trans-common.c
parentd9cdfea55f31e461e54db7039fbc2281824ef527 (diff)
downloadgcc-dc8c7978e0cab480de3f932d1cb76d7bf5e72816.zip
gcc-dc8c7978e0cab480de3f932d1cb76d7bf5e72816.tar.gz
gcc-dc8c7978e0cab480de3f932d1cb76d7bf5e72816.tar.bz2
re PR fortran/45044 (Different named COMMON block size: No warning)
2011-08-30 Tobias Burnus <burnus@net-b.de> PR fortran/45044 * trans-common.c (build_common_decl): Warn if named common block's size is not everywhere the same. 2011-08-30 Tobias Burnus <burnus@net-b.de> PR fortran/45044 * gfortran.dg/common_14.f90: New. * gfortran.dg/common_resize_1.f: Add two dg-warning. From-SVN: r178344
Diffstat (limited to 'gcc/fortran/trans-common.c')
-rw-r--r--gcc/fortran/trans-common.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index c289bbe..21237c8 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -390,14 +390,20 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init)
if (decl != NULL_TREE)
{
tree size = TYPE_SIZE_UNIT (union_type);
+
+ /* Named common blocks of the same name shall be of the same size
+ in all scoping units of a program in which they appear, but
+ blank common blocks may be of different sizes. */
+ 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 as elsewhere (%lu vs %lu bytes)", com->name,
+ &com->where,
+ (unsigned long) TREE_INT_CST_LOW (size),
+ (unsigned long) TREE_INT_CST_LOW (DECL_SIZE_UNIT (decl)));
+
if (tree_int_cst_lt (DECL_SIZE_UNIT (decl), size))
- {
- /* Named common blocks of the same name shall be of the same size
- in all scoping units of a program in which they appear, but
- 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);
DECL_SIZE_UNIT (decl) = size;
DECL_MODE (decl) = TYPE_MODE (union_type);