This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch,Fortran] PRs 40588/22423 minor fixes
- From: Tobias Burnus <burnus at net-b dot de>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Sun, 12 Jul 2009 20:46:52 +0200
- Subject: [Patch,Fortran] PRs 40588/22423 minor fixes
Dear all,
attached are three minor patches, which are on the verge of
being obvious.
a) PR 40588: Philippe Marguinaud reported that the logic in
match_charkind_name is wrong. The result is that too much
is accepted, instead of rejecting all special characters,
except of '$' - and the latter only if -fdollar-ok is used.
The practial relevance is presumably zero as match_name is
called first, which already rejects invalid characters.
Still, it is useful to have the correct logic.
Currently:
if (!ISALNUM (c)
&& c != '_'
&& (gfc_option.flag_dollar_ok && c != '$'))
break; /* Return if the letter is invalid. */
The correct version is either:
&& !(gfc_option.flag_dollar_ok && c == '$'))
^^^ ^^
or equivalently
&& (!gfc_option.flag_dollar_ok || c != '$'))
^^^ ^^
b) PR 22423: We got i a warning because the variable "ub" was
not always initialized. I replaced the if conditions by
a switch block, including an unreachable.
c) PR 22423: We were using the wrong ENUM for namelist types;
this gave warnings when doing <enum type> = <integer>
assignments as the RHS had integers exceeding the range of
the used enum. The fix is simple: Use the proper enum.
Build and regtested on x86-64-linux.
OK for the trunk?
Tobias
2009-07-12 Tobias Burnus <burnus@net-b.de>
Philippe Marguinaud <philippe.marguinaud@meteo.fr>
PR fortran/40588
* primary.c (match_charkind_name): Fix condition for $ matching.
PR libfortran/22423
* libgfortran.h: Typedef the GFC_DTYPE_* enum.
2009-07-12 Tobias Burnus <burnus@net-b.de>
PR libfortran/22423
* io/io.h (namelist_type): Use the proper enum for GFC_DTYPE_*.
* intrinsics/iso_c_binding.c (c_f_pointer_u0): Make sure
variable is initialized to silence warning.
Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c (Revision 149530)
+++ gcc/fortran/primary.c (Arbeitskopie)
@@ -832,7 +832,7 @@ match_charkind_name (char *name)
if (!ISALNUM (c)
&& c != '_'
- && (gfc_option.flag_dollar_ok && c != '$'))
+ && (c != '$' || !gfc_option.flag_dollar_ok))
break;
*name++ = c;
Index: gcc/fortran/libgfortran.h
===================================================================
--- gcc/fortran/libgfortran.h (Revision 149530)
+++ gcc/fortran/libgfortran.h (Arbeitskopie)
@@ -110,7 +110,7 @@ libgfortran_error_codes;
#define GFC_DTYPE_TYPE_MASK 0x38
#define GFC_DTYPE_SIZE_SHIFT 6
-enum
+typedef enum
{
GFC_DTYPE_UNKNOWN = 0,
GFC_DTYPE_INTEGER,
@@ -120,5 +120,6 @@ enum
GFC_DTYPE_COMPLEX,
GFC_DTYPE_DERIVED,
GFC_DTYPE_CHARACTER
-};
+}
+dtype;
Index: libgfortran/intrinsics/iso_c_binding.c
===================================================================
--- libgfortran/intrinsics/iso_c_binding.c (Revision 149530)
+++ libgfortran/intrinsics/iso_c_binding.c (Arbeitskopie)
@@ -113,26 +113,36 @@ ISO_C_BINDING_PREFIX (c_f_pointer_u0) (v
/* Have to allow for the SHAPE array to be any valid kind for
an INTEGER type. */
+ switch (size)
+ {
#ifdef HAVE_GFC_INTEGER_1
- if (size == 1)
- ub = *((GFC_INTEGER_1 *) p);
+ case 1:
+ ub = *((GFC_INTEGER_1 *) p);
+ break;
#endif
#ifdef HAVE_GFC_INTEGER_2
- if (size == 2)
- ub = *((GFC_INTEGER_2 *) p);
+ case 2:
+ ub = *((GFC_INTEGER_2 *) p);
+ break;
#endif
#ifdef HAVE_GFC_INTEGER_4
- if (size == 4)
- ub = *((GFC_INTEGER_4 *) p);
+ case 4:
+ ub = *((GFC_INTEGER_4 *) p);
+ break;
#endif
#ifdef HAVE_GFC_INTEGER_8
- if (size == 8)
- ub = *((GFC_INTEGER_8 *) p);
+ case 8:
+ ub = *((GFC_INTEGER_8 *) p);
+ break;
#endif
#ifdef HAVE_GFC_INTEGER_16
- if (size == 16)
- ub = *((GFC_INTEGER_16 *) p);
+ case 16:
+ ub = *((GFC_INTEGER_16 *) p);
+ break;
#endif
+ default:
+ internal_error (NULL, "c_f_pointer_u0: Invalid size");
+ }
p += source_stride;
if (i == 0)
Index: libgfortran/io/io.h
===================================================================
--- libgfortran/io/io.h (Revision 149530)
+++ libgfortran/io/io.h (Arbeitskopie)
@@ -163,7 +163,7 @@ format_hash_entry;
typedef struct namelist_type
{
/* Object type, stored as GFC_DTYPE_xxxx. */
- bt type;
+ dtype type;
/* Object name. */
char * var_name;