Summary: | BOZ editing of real numbers not working with -std=f2008 | ||
---|---|---|---|
Product: | gcc | Reporter: | Thomas Henlich <thenlich> |
Component: | libfortran | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jvdelisle2 |
Priority: | P3 | ||
Version: | 4.7.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | ||
Attachments: |
Proposed patch for input/output
Test case for input/output of real numbers with B/O/Z editing |
Description
Thomas Henlich
2011-04-27 06:22:52 UTC
In libgfortran/io/transfer.c's one currently has in formatted_transfer_scalar_read and formatted_transfer_scalar_write code such as case FMT_B: if (n == 0) goto need_data; if (!(compile_options.allow_std & GFC_STD_GNU) && require_type (dtp, BT_INTEGER, type, f)) return; write_b (dtp, f, p, kind); break; s/GFC_STD_GNU/GFC_STD_F2008/ should take care of that. However, that might accept too much, namely CHARACTER and LOGICAL, which are excluded at: "The corresponding input/output list item shall be of type integer, real, or complex." I don't know whether we should care - I tend to be more liberal for run-time diagnostic than for compile-time diagnostic ... Created attachment 24162 [details]
Proposed patch for input/output
Created attachment 24163 [details]
Test case for input/output of real numbers with B/O/Z editing
Thanks Thomas, thanks for support. I will have a close look and check tonight. (In reply to comment #2) > Created attachment 24162 [details] > Proposed patch for input/output - if (!(compile_options.allow_std & GFC_STD_GNU) + if (!(compile_options.allow_std & (GFC_STD_GNU | GFC_STD_F2008)) As mentioned in comment 1, replacing GFC_STD_GNU by GFC_STD_F2008 should be sufficient without OR-ing the two. Can you elaborate on this? Previously we allowed the format with -std=gnu. Now we want to allow it with -std=gnu or -std=f2008. So we call require_type() only if neither of these options is set. That's why I changed the mask from GFC_STD_GNU to (GFC_STD_GNU | GFC_STD_F2008). And the values have different bits set, so the OR is not redundant: #define GFC_STD_F2008 (1<<7) /* New in F2008. */ #define GFC_STD_LEGACY (1<<6) /* Backward compatibility. */ #define GFC_STD_GNU (1<<5) /* GNU Fortran extension. */ (In reply to comment #6) > Can you elaborate on this? > That's why I changed the mask from GFC_STD_GNU to (GFC_STD_GNU | > GFC_STD_F2008). First, the code is/should be also allowed for -std=legacy (GFC_STD_LEGACY). Secondly, the point is not that GFC_STD_GNU and GFC_STD_F2008 are same (they obviously aren't), but that having (compile_options.allow_std | GFC_STD_F2008) != 0 => implies (compile_options.allow_std | GFC_STD_GNU) != 0 which is a property of "allow_std". See gcc/fortran/options.c: case OPT_std_f2003: gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008_OBS; case OPT_std_f2008: gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77 | GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS; case OPT_std_gnu: set_default_std_flags (); break; (In reply to comment #7) O, I see. The important part is in 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_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY; } So technically, we only need to test for GFC_STD_F2008, just as you said. Looking at transfer.c and trying the test case provided here, I believe this is fixed. Closing. |