From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18839 invoked by alias); 1 Sep 2009 20:58:04 -0000 Received: (qmail 18787 invoked by uid 48); 1 Sep 2009 20:57:53 -0000 Date: Tue, 01 Sep 2009 20:58:00 -0000 Subject: [Bug fortran/41218] New: Vendor extension: character assignment in DATA to non-character variables X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg00079.txt.bz2 http://gcc.gnu.org/ml/fortran/2009-09/msg00003.html g77 - but also openf95, sunf95 or ifort - support the following Fortran 66 vendor extension, which was effectively obsoleted by Fortran 77. LOGICAL :: L INTEGER :: I REAL :: R DATA L/'abcd'/, I/'Text'/, R/'ZYXW'/ ! Missing legacy extension print *, L, transfer(L,"1234") print *, I, transfer(I,"1234") print *, R, transfer(R,"1234") END Tim wrote: "Hollerith constant expressed with apostrophes was a vendor extension to f66, typically supported by IBM and HP but few others. Its use was often a sign of intentional non-portability. In order to support the extension in f77, it involved the new extension of supporting character strings to assign and initialize Hollerith." * * * One needs to add a conversion similar as done in gfc_simplify_transfer - with the proper warning if the string is too long (ignored characters) or too short (undefined value) - somewhere in gfc_check_assign. The first steps will be: Index: expr.c =================================================================== --- expr.c (revision 151272) +++ expr.c (working copy) @@ -3021,6 +3021,18 @@ gfc_check_assign (gfc_expr *lvalue, gfc_ if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL) return SUCCESS; + if ((gfc_numeric_ts (&lvalue->ts) || lvalue->ts.type == BT_LOGICAL) + && rvalue->ts.type == BT_CHARACTER) + { + if (gfc_notify_std (GFC_STD_LEGACY, "Legacy: Assigning character " + "literal in DATA statement at %L to a noncharacter " + "variable", &rvalue->where) == FAILURE) + return FAILURE; + +FIXME: Do actual conversion similar to gfc_simplify_transfer + (incl. too long/too shortwarnings) + + } + gfc_error ("Incompatible types in DATA statement at %L; attempted " "conversion of %s to %s", &lvalue->where, gfc_typename (&rvalue->ts), gfc_typename (&lvalue->ts)); -- Summary: Vendor extension: character assignment in DATA to non- character variables Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41218