Bug 50515 - gfortran should not accept an external that is a common (r178939)
Summary: gfortran should not accept an external that is a common (r178939)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 minor
Target Milestone: ---
Assignee: janus
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2011-09-25 20:05 UTC by Vittorio Zecca
Modified: 2011-09-26 20:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-09-26 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2011-09-25 20:05:41 UTC
! gfortran should not accept an external that is a common (r178939)
      common/sub/ a
      external sub
      end
Comment 1 janus 2011-09-26 07:41:11 UTC
Trivial patch:

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 179143)
+++ gcc/fortran/resolve.c	(working copy)
@@ -905,6 +905,10 @@ resolve_common_blocks (gfc_symtree *common_root)
     gfc_error ("COMMON block '%s' at %L is used as PARAMETER at %L",
 	       sym->name, &common_root->n.common->where, &sym->declared_at);
 
+  if (sym->attr.external)
+    gfc_error ("COMMON block '%s' at %L can not have the EXTERNAL attribute",
+	       sym->name, &common_root->n.common->where);
+
   if (sym->attr.intrinsic)
     gfc_error ("COMMON block '%s' at %L is also an intrinsic procedure",
 	       sym->name, &common_root->n.common->where);
Comment 2 janus 2011-09-26 20:05:57 UTC
Author: janus
Date: Mon Sep 26 20:05:43 2011
New Revision: 179213

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179213
Log:
2011-09-26  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/50515
	* resolve.c (resolve_common_blocks): Check for EXTERNAL attribute.

	PR fortran/50517
	* interface.c (gfc_compare_interfaces): Bugfix in check for result type.


2011-09-26  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/50515
	* gfortran.dg/common_15.f90: New.

	PR fortran/50517
	* gfortran.dg/dummy_procedure_5.f90: New.
	* gfortran.dg/interface_26.f90: Modified error message.
	* gfortran.dg/proc_ptr_11.f90: Ditto.
	* gfortran.dg/proc_ptr_15.f90: Ditto.
	* gfortran.dg/proc_ptr_comp_20.f90: Ditto.
	* gfortran.dg/proc_ptr_result_5.f90: Ditto.

Added:
    trunk/gcc/testsuite/gfortran.dg/common_15.f90
    trunk/gcc/testsuite/gfortran.dg/dummy_procedure_5.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/interface.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/interface_26.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_11.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_15.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_20.f90
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_result_5.f90
Comment 3 janus 2011-09-26 20:13:25 UTC
Fixed with r179213. Closing.