summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-18 11:10:11 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2008-05-18 11:10:11 +0000
commitd1743da1fffc7986bd0d6dfd363f1ee840f89629 (patch)
treeb5aae94d05b87de03144816296f9b337ec01f650 /gcc
parent5ade25c666148121dba620efbfd466f6b86cca58 (diff)
downloadgcc-d1743da1fffc7986bd0d6dfd363f1ee840f89629.tar.gz
2008-05-18 Steven G. Kargl <kargls@comcast.net>
PR fortran/36251 * symbol.c (check_conflict): Issue errors for abuse of PUBLIC, * PRIVATE, and BIND(C). * resolve.c (gfc_verify_binding_labels): Fix NULL pointer * dereference. 2008-05-18 Steven G. Kargl <kargls@comcast.net> PR fortran/36251 gfortran.dg/public_private_module.f90: new test. gfortran.dg/bind_c_module.f90: new test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135495 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog11
-rw-r--r--gcc/fortran/resolve.c8
-rw-r--r--gcc/fortran/symbol.c18
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gfortran.dg/bind_c_module.f9022
-rw-r--r--gcc/testsuite/gfortran.dg/public_private_module.f9019
6 files changed, 77 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 38cdafc6eaa..35c564c4848 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,11 +1,18 @@
-2008-05-16 Tobias Burnus <burnus@net-b.de>
+2008-05-18 Steven G. Kargl <kargls@comcast.net>
+
+ PR fortran/36251
+ * symbol.c (check_conflict): Issue errors for abuse of PUBLIC, PRIVATE,
+ and BIND(C).
+ * resolve.c (gfc_verify_binding_labels): Fix NULL pointer dereference.
+
+2008-05-17 Tobias Burnus <burnus@net-b.de>
* intrinsic.texi: Correct description of GET_COMMAND_ARGUMENT
and GET_ENVIRONMENT_VARIABLE; fix keyword= name for GETENV,
GETLOG, GMTIME, HOSTNM, IRAND, ITIME, KILL.
Move LOG_GAMMA after LOG10.
-2008-05-16 Tobias Burnus <burnus@net-b.de>
+2008-05-17 Tobias Burnus <burnus@net-b.de>
* intrinsic.c (add_functions): Change FLUSH(C) to FLUSH(UNIT).
* intrinsic.texi: Change INTEGER(*) to INTEGER; fix keyword= name for
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index bf886240061..dd251af37b6 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -6612,10 +6612,10 @@ gfc_verify_binding_labels (gfc_symbol *sym)
has_error = 1;
}
else if (sym->attr.contained == 0
- && (sym->attr.if_source == IFSRC_UNKNOWN))
- if ((sym->attr.use_assoc
- && (strcmp (bind_c_sym->mod_name, sym->module) != 0))
- || sym->attr.use_assoc == 0)
+ && sym->attr.if_source == IFSRC_UNKNOWN)
+ if ((sym->attr.use_assoc && bind_c_sym->mod_name
+ && strcmp (bind_c_sym->mod_name, sym->module) != 0)
+ || sym->attr.use_assoc == 0)
{
gfc_error ("Binding label '%s' at %L collides with global "
"entity '%s' at %L", sym->binding_label,
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 7f79ee38d6a..431b6513ce0 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -595,6 +595,21 @@ check_conflict (symbol_attribute *attr, const char *name, locus *where)
conf2 (function);
conf2 (subroutine);
conf2 (threadprivate);
+
+ if (attr->access == ACCESS_PUBLIC || attr->access == ACCESS_PRIVATE)
+ {
+ a2 = attr->access == ACCESS_PUBLIC ? public : private;
+ gfc_error ("%s attribute applied to %s %s at %L", a2, a1,
+ name, where);
+ return FAILURE;
+ }
+
+ if (attr->is_bind_c)
+ {
+ gfc_error_now ("BIND(C) applied to %s %s at %L", a1, name, where);
+ return FAILURE;
+ }
+
break;
case FL_VARIABLE:
@@ -3625,7 +3640,8 @@ add_proc_interface (gfc_symbol *sym, ifsrc source,
declaration statement (see match_proc_decl()) to create the formal
args based on the args of a given named interface. */
-void copy_formal_args (gfc_symbol *dest, gfc_symbol *src)
+void
+copy_formal_args (gfc_symbol *dest, gfc_symbol *src)
{
gfc_formal_arglist *head = NULL;
gfc_formal_arglist *tail = NULL;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 65aa1e23dde..d7ad2ec1bd3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-18 Steven G. Kargl <kargls@comcast.net>
+
+ PR fortran/36251
+ gfortran.dg/public_private_module.f90: new test.
+ gfortran.dg/bind_c_module.f90: new test.
+
2008-05-17 Xinliang David Li <davidxl@google.com>
* gcc.dg/cdce1.c: New test
diff --git a/gcc/testsuite/gfortran.dg/bind_c_module.f90 b/gcc/testsuite/gfortran.dg/bind_c_module.f90
new file mode 100644
index 00000000000..58aba2b345b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/bind_c_module.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! See PR fortran/36251.
+module a
+ implicit none
+ integer :: i = 42
+end module a
+
+! Causes ICE
+module b
+ use iso_c_binding
+ use a
+ implicit none
+ bind(c) :: a ! { dg-error "attribute applied to" }
+end module b
+
+! Causes ICE
+module d
+ use a
+ implicit none
+ bind(c) :: a ! { dg-error "attribute applied to" }
+end module d
+! { dg-final { cleanup-modules "a" } }
diff --git a/gcc/testsuite/gfortran.dg/public_private_module.f90 b/gcc/testsuite/gfortran.dg/public_private_module.f90
new file mode 100644
index 00000000000..ca1ab4891f4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/public_private_module.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! See PR fortran/36251.
+module a
+ implicit none
+ integer :: i = 42
+end module a
+
+module b
+ use a
+ implicit none
+ public a ! { dg-warning "attribute applied to" }
+end module b
+
+module d
+ use a
+ implicit none
+ private a ! { dg-warning "attribute applied to" }
+end module d
+! { dg-final { cleanup-modules "a" } }