Commit 2e8d9212 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/48858 (Incorrect error for same binding label on two generic interface specifics)

2011-05-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/48858
        PR fortran/48820
        * lang.opt (std=f2008tr): New.
        * libgfortran.h (GFC_STD_F2008_TR): New macro constant.
        * decl.c (verify_c_interop_param): Allow OPTIONAL in BIND(C)
        procedures for -std=f2008tr/gnu/legacy.

2011-05-06  Tobias Burnus  <burnus@net-b.de>

        PR fortran/48858
        PR fortran/48820
        * gfortran.dg/bind_c_usage_22.f90: New.
        * gfortran.dg/bind_c_usage_23.f90: New.
        * gfortran.dg/bind_c_usage_24.f90: New.
        * gfortran.dg/bind_c_usage_24_c.c: New.

From-SVN: r173500
parent 80bde45b
2011-05-06 Tobias Burnus <burnus@net-b.de>
PR fortran/48858
PR fortran/48820
* lang.opt (std=f2008tr): New.
* libgfortran.h (GFC_STD_F2008_TR): New macro constant.
* decl.c (verify_c_interop_param): Allow OPTIONAL in BIND(C)
procedures for -std=f2008tr/gnu/legacy.
(gfc_match_import): Set sym to NULL.
* options.c (set_default_std_flags,gfc_handle_option): Handle
-std=f2008tr.
* invoke.texi (-std=): Document -std=f2008tr.
2011-05-05 Nathan Froyd <froydnj@codesourcery.com>
* trans-decl.c (gfc_trans_entry_master_switch): Call build_case_label.
......
......@@ -1060,14 +1060,22 @@ verify_c_interop_param (gfc_symbol *sym)
retval = FAILURE;
}
if (sym->attr.optional == 1)
if (sym->attr.optional == 1 && sym->attr.value)
{
gfc_error ("Variable '%s' at %L cannot have the "
"OPTIONAL attribute because procedure '%s'"
" is BIND(C)", sym->name, &(sym->declared_at),
gfc_error ("Variable '%s' at %L cannot have both the OPTIONAL "
"and the VALUE attribute because procedure '%s' "
"is BIND(C)", sym->name, &(sym->declared_at),
sym->ns->proc_name->name);
retval = FAILURE;
}
else if (sym->attr.optional == 1
&& gfc_notify_std (GFC_STD_F2008_TR, "TR29113: Variable '%s' "
"at %L with OPTIONAL attribute in "
"procedure '%s' which is BIND(C)",
sym->name, &(sym->declared_at),
sym->ns->proc_name->name)
== FAILURE)
retval = FAILURE;
/* Make sure that if it has the dimension attribute, that it is
either assumed size or explicit shape. */
......@@ -2985,6 +2993,7 @@ gfc_match_import (void)
for(;;)
{
sym = NULL;
m = gfc_match (" %n", name);
switch (m)
{
......
......@@ -368,7 +368,9 @@ extensions, and may be useful for old non-standard programs. The
conformance to the Fortran 95, Fortran 2003 and Fortran 2008 standards,
respectively; errors are given for all extensions beyond the relevant
language standard, and warnings are given for the Fortran 77 features
that are permitted but obsolescent in later standards.
that are permitted but obsolescent in later standards. @samp{-std=f2008tr}
allows the Fortran 2008 standard including the additions of the
technical report (TR) 29113.
@end table
......
......@@ -590,6 +590,10 @@ std=f2008
Fortran
Conform to the ISO Fortran 2008 standard
std=f2008tr
Fortran
Conform to the ISO Fortran 2008 standard including TR 29113
std=f95
Fortran
Conform to the ISO Fortran 95 standard
......
......@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
Note that no features were obsoleted nor deleted in F2003.
Please remember to keep those definitions in sync with
gfortran.texi. */
#define GFC_STD_F2008_TR (1<<9) /* POST-F2008 technical reports. */
#define GFC_STD_F2008_OBS (1<<8) /* Obsolescent in F2008. */
#define GFC_STD_F2008 (1<<7) /* New in F2008. */
#define GFC_STD_LEGACY (1<<6) /* Backward compatibility. */
......
......@@ -49,7 +49,7 @@ set_default_std_flags (void)
{
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
| GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY;
| GFC_STD_F2008_OBS | GFC_STD_F2008_TR | GFC_STD_GNU | GFC_STD_LEGACY;
gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
}
......@@ -945,6 +945,16 @@ gfc_handle_option (size_t scode, const char *arg, int value,
gfc_option.warn_tabs = 0;
break;
case OPT_std_f2008tr:
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
| GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS
| GFC_STD_F2008_TR;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
gfc_option.max_identifier_length = 63;
gfc_option.warn_ampersand = 1;
gfc_option.warn_tabs = 0;
break;
case OPT_std_gnu:
set_default_std_flags ();
break;
......
2011-05-06 Tobias Burnus <burnus@net-b.de>
PR fortran/48858
PR fortran/48820
* gfortran.dg/bind_c_usage_22.f90: New.
* gfortran.dg/bind_c_usage_23.f90: New.
* gfortran.dg/bind_c_usage_24.f90: New.
* gfortran.dg/bind_c_usage_24_c.c: New.
2011-05-06 Dodji Seketeli <dodji@redhat.com>
PR c++/48838
......
! { dg-do compile }
! { dg-options "-std=f2008tr" }
!
! PR fortran/48858
! PR fortran/48820
!
! OPTIONAL + BIND(C) is allowed since TR 29113
!
! VALID
subroutine sub(z) bind(C)
use iso_c_binding
integer(c_int), value :: z
end subroutine sub
! VALID since TR29113
subroutine sub2(z) bind(C)
use iso_c_binding
integer(c_int), optional :: z
end subroutine sub2
! VALID since TR29113
subroutine sub2a(z) bind(C)
use iso_c_binding
integer(c_int) :: z
optional :: z
end subroutine sub2a
! VALID since TR29113
subroutine sub2b(z) bind(C)
use iso_c_binding
optional :: z
integer(c_int) :: z
end subroutine sub2b
! Invalid
subroutine sub3(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
integer(c_int), value, optional :: z
end subroutine sub3
! Invalid
subroutine sub3a(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
integer(c_int) :: z
optional :: z
value :: z
end subroutine sub3a
! Invalid
subroutine sub3b(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
optional :: z
value :: z
integer(c_int) :: z
end subroutine sub3b
! Invalid
subroutine sub3c(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
value :: z
integer(c_int) :: z
optional :: z
end subroutine sub3c
! { dg-do compile }
! { dg-options "-std=f2008" }
!
! PR fortran/48858
! PR fortran/48820
!
! OPTIONAL + BIND(C) is allowed since TR 29113
!
! VALID
subroutine sub(z) bind(C)
use iso_c_binding
integer(c_int), value :: z
end subroutine sub
! VALID since TR29113
subroutine sub2(z) bind(C) ! { dg-error "with OPTIONAL attribute in procedure" }
use iso_c_binding
integer(c_int), optional :: z
end subroutine sub2
! VALID since TR29113
subroutine sub2a(z) bind(C) ! { dg-error "with OPTIONAL attribute in procedure" }
use iso_c_binding
integer(c_int) :: z
optional :: z
end subroutine sub2a
! VALID since TR29113
subroutine sub2b(z) bind(C) ! { dg-error "with OPTIONAL attribute in procedure" }
use iso_c_binding
optional :: z
integer(c_int) :: z
end subroutine sub2b
! Invalid
subroutine sub3(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
integer(c_int), value, optional :: z
end subroutine sub3
! Invalid
subroutine sub3a(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
integer(c_int) :: z
optional :: z
value :: z
end subroutine sub3a
! Invalid
subroutine sub3b(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
optional :: z
value :: z
integer(c_int) :: z
end subroutine sub3b
! Invalid
subroutine sub3c(z) bind(C) ! { dg-error "cannot have both the OPTIONAL and the VALUE attribute" }
use iso_c_binding
value :: z
integer(c_int) :: z
optional :: z
end subroutine sub3c
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment