Commit 8fc541d3 by Francois-Xavier Coudert Committed by François-Xavier Coudert

openmp.c (gfc_match_omp_eos): Use gfc_next_ascii_char and gfc_peek_ascii_char.

	* openmp.c (gfc_match_omp_eos): Use gfc_next_ascii_char and
	gfc_peek_ascii_char.
	* decl.c (gfc_match_kind_spec, gfc_match_type_spec,
	gfc_match_implicit_none, match_implicit_range, gfc_match_implicit,
	match_string_p, match_attr_spec, gfc_match_suffix,
	match_procedure_decl, gfc_match_entry, gfc_match_subroutine):
	Likewise.
	* gfortran.h (gfc_char_t): New type.
	(gfc_linebuf): Make line member a gfc_char_t.
	(locus): Make nextc member a gfc_char_t.
	(gfc_wide_is_printable, gfc_wide_is_digit, gfc_wide_fits_in_byte,
	gfc_wide_tolower, gfc_wide_strlen, gfc_next_ascii_char,
	gfc_peek_ascii_char, gfc_check_digit): New prototypes.
	* error.c (print_wide_char): New function.
	(show_locus): Use print_wide_char and gfc_wide_strlen.
	* io.c (next_char): Use gfc_char_t type.
	(match_io): Use gfc_peek_ascii_char and gfc_next_ascii_char.
	* match.c (gfc_match_parens, gfc_match_eos,
	gfc_match_small_literal_int, gfc_match_name, gfc_match_name_C,
	gfc_match_intrinsic_op, gfc_match_char,  gfc_match_return,
	gfc_match_common): Likewise.
	* match.h (gfc_match_special_char): Change prototype.
	* parse.c (decode_specification_statement, decode_statement,
	decode_omp_directive, next_free, next_fixed): Use
	gfc_peek_ascii_char and gfc_next_ascii_char.
	* primary.c (gfc_check_digit): Change name.
	(match_digits, match_hollerith_constant, match_boz_constant,
	match_real_constant, next_string_char, match_charkind_name,
	match_string_constant, match_logical_constant_string,
	match_complex_constant, match_actual_arg, match_varspec,
	gfc_match_rvalue, match_variable): Use gfc_peek_ascii_char and
	gfc_next_ascii_char.
	* scanner.c (gfc_wide_fits_in_byte, wide_is_ascii,
	gfc_wide_is_printable, gfc_wide_tolower, gfc_wide_is_digit,
	gfc_wide_is_digit, wide_atoi, gfc_wide_strlen, wide_strcpy,
	wide_strchr, widechar_to_char, wide_strncmp, wide_strncasecmp,
	gfc_next_ascii_char, gfc_peek_ascii_char):
	New functions.
	(next_char, gfc_define_undef_line, skip_free_comments,
	gfc_next_char_literal, gfc_next_char, gfc_peek_char,
	gfc_error_recovery, load_line, preprocessor_line, include_line,
	load_file, gfc_read_orig_filename): Use gfc_char_t for source
	characters and the {gfc_,}wide_* functions to manipulate wide
	strings.

From-SVN: r134992
parent d0b48c67
2008-05-06 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* openmp.c (gfc_match_omp_eos): Use gfc_next_ascii_char and
gfc_peek_ascii_char.
* decl.c (gfc_match_kind_spec, gfc_match_type_spec,
gfc_match_implicit_none, match_implicit_range, gfc_match_implicit,
match_string_p, match_attr_spec, gfc_match_suffix,
match_procedure_decl, gfc_match_entry, gfc_match_subroutine):
Likewise.
* gfortran.h (gfc_char_t): New type.
(gfc_linebuf): Make line member a gfc_char_t.
(locus): Make nextc member a gfc_char_t.
(gfc_wide_is_printable, gfc_wide_is_digit, gfc_wide_fits_in_byte,
gfc_wide_tolower, gfc_wide_strlen, gfc_next_ascii_char,
gfc_peek_ascii_char, gfc_check_digit): New prototypes.
* error.c (print_wide_char): New function.
(show_locus): Use print_wide_char and gfc_wide_strlen.
* io.c (next_char): Use gfc_char_t type.
(match_io): Use gfc_peek_ascii_char and gfc_next_ascii_char.
* match.c (gfc_match_parens, gfc_match_eos,
gfc_match_small_literal_int, gfc_match_name, gfc_match_name_C,
gfc_match_intrinsic_op, gfc_match_char, gfc_match_return,
gfc_match_common): Likewise.
* match.h (gfc_match_special_char): Change prototype.
* parse.c (decode_specification_statement, decode_statement,
decode_omp_directive, next_free, next_fixed): Use
gfc_peek_ascii_char and gfc_next_ascii_char.
* primary.c (gfc_check_digit): Change name.
(match_digits, match_hollerith_constant, match_boz_constant,
match_real_constant, next_string_char, match_charkind_name,
match_string_constant, match_logical_constant_string,
match_complex_constant, match_actual_arg, match_varspec,
gfc_match_rvalue, match_variable): Use gfc_peek_ascii_char and
gfc_next_ascii_char.
* scanner.c (gfc_wide_fits_in_byte, wide_is_ascii,
gfc_wide_is_printable, gfc_wide_tolower, gfc_wide_is_digit,
gfc_wide_is_digit, wide_atoi, gfc_wide_strlen, wide_strcpy,
wide_strchr, widechar_to_char, wide_strncmp, wide_strncasecmp,
gfc_next_ascii_char, gfc_peek_ascii_char):
New functions.
(next_char, gfc_define_undef_line, skip_free_comments,
gfc_next_char_literal, gfc_next_char, gfc_peek_char,
gfc_error_recovery, load_line, preprocessor_line, include_line,
load_file, gfc_read_orig_filename): Use gfc_char_t for source
characters and the {gfc_,}wide_* functions to manipulate wide
strings.
2008-05-06 Tobias Burnus <burnus@net-b.de> 2008-05-06 Tobias Burnus <burnus@net-b.de>
PR fortran/36117 PR fortran/36117
......
...@@ -1940,7 +1940,8 @@ kind_expr: ...@@ -1940,7 +1940,8 @@ kind_expr:
} }
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
if ((c = gfc_next_char ()) != ')' && (ts->type != BT_CHARACTER || c != ',')) if ((c = gfc_next_ascii_char ()) != ')'
&& (ts->type != BT_CHARACTER || c != ','))
{ {
if (ts->type == BT_CHARACTER) if (ts->type == BT_CHARACTER)
gfc_error ("Missing right parenthesis or comma at %C"); gfc_error ("Missing right parenthesis or comma at %C");
...@@ -2213,7 +2214,7 @@ gfc_match_type_spec (gfc_typespec *ts, int implicit_flag) ...@@ -2213,7 +2214,7 @@ gfc_match_type_spec (gfc_typespec *ts, int implicit_flag)
char name[GFC_MAX_SYMBOL_LEN + 1]; char name[GFC_MAX_SYMBOL_LEN + 1];
gfc_symbol *sym; gfc_symbol *sym;
match m; match m;
int c; char c;
bool seen_deferred_kind; bool seen_deferred_kind;
/* A belt and braces check that the typespec is correctly being treated /* A belt and braces check that the typespec is correctly being treated
...@@ -2360,7 +2361,7 @@ get_kind: ...@@ -2360,7 +2361,7 @@ get_kind:
if (gfc_current_form == FORM_FREE) if (gfc_current_form == FORM_FREE)
{ {
c = gfc_peek_char(); c = gfc_peek_ascii_char();
if (!gfc_is_whitespace(c) && c != '*' && c != '(' if (!gfc_is_whitespace(c) && c != '*' && c != '('
&& c != ':' && c != ',') && c != ':' && c != ',')
return MATCH_NO; return MATCH_NO;
...@@ -2400,13 +2401,14 @@ gfc_match_implicit_none (void) ...@@ -2400,13 +2401,14 @@ gfc_match_implicit_none (void)
static match static match
match_implicit_range (void) match_implicit_range (void)
{ {
int c, c1, c2, inner; char c, c1, c2;
int inner;
locus cur_loc; locus cur_loc;
cur_loc = gfc_current_locus; cur_loc = gfc_current_locus;
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c = gfc_next_char (); c = gfc_next_ascii_char ();
if (c != '(') if (c != '(')
{ {
gfc_error ("Missing character range in IMPLICIT at %C"); gfc_error ("Missing character range in IMPLICIT at %C");
...@@ -2417,12 +2419,12 @@ match_implicit_range (void) ...@@ -2417,12 +2419,12 @@ match_implicit_range (void)
while (inner) while (inner)
{ {
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c1 = gfc_next_char (); c1 = gfc_next_ascii_char ();
if (!ISALPHA (c1)) if (!ISALPHA (c1))
goto bad; goto bad;
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c = gfc_next_char (); c = gfc_next_ascii_char ();
switch (c) switch (c)
{ {
...@@ -2435,12 +2437,12 @@ match_implicit_range (void) ...@@ -2435,12 +2437,12 @@ match_implicit_range (void)
case '-': case '-':
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c2 = gfc_next_char (); c2 = gfc_next_ascii_char ();
if (!ISALPHA (c2)) if (!ISALPHA (c2))
goto bad; goto bad;
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c = gfc_next_char (); c = gfc_next_ascii_char ();
if ((c != ',') && (c != ')')) if ((c != ',') && (c != ')'))
goto bad; goto bad;
...@@ -2503,7 +2505,7 @@ gfc_match_implicit (void) ...@@ -2503,7 +2505,7 @@ gfc_match_implicit (void)
{ {
gfc_typespec ts; gfc_typespec ts;
locus cur_loc; locus cur_loc;
int c; char c;
match m; match m;
gfc_clear_ts (&ts); gfc_clear_ts (&ts);
...@@ -2534,7 +2536,7 @@ gfc_match_implicit (void) ...@@ -2534,7 +2536,7 @@ gfc_match_implicit (void)
{ {
/* We may have <TYPE> (<RANGE>). */ /* We may have <TYPE> (<RANGE>). */
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c = gfc_next_char (); c = gfc_next_ascii_char ();
if ((c == '\n') || (c == ',')) if ((c == '\n') || (c == ','))
{ {
/* Check for CHARACTER with no length parameter. */ /* Check for CHARACTER with no length parameter. */
...@@ -2584,7 +2586,7 @@ gfc_match_implicit (void) ...@@ -2584,7 +2586,7 @@ gfc_match_implicit (void)
goto syntax; goto syntax;
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c = gfc_next_char (); c = gfc_next_ascii_char ();
if ((c != '\n') && (c != ',')) if ((c != '\n') && (c != ','))
goto syntax; goto syntax;
...@@ -2713,7 +2715,7 @@ match_string_p (const char *target) ...@@ -2713,7 +2715,7 @@ match_string_p (const char *target)
const char *p; const char *p;
for (p = target; *p; p++) for (p = target; *p; p++)
if (gfc_next_char () != *p) if ((char) gfc_next_ascii_char () != *p)
return false; return false;
return true; return true;
} }
...@@ -2765,22 +2767,22 @@ match_attr_spec (void) ...@@ -2765,22 +2767,22 @@ match_attr_spec (void)
for (;;) for (;;)
{ {
int ch; char ch;
d = DECL_NONE; d = DECL_NONE;
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
ch = gfc_next_char (); ch = gfc_next_ascii_char ();
if (ch == ':') if (ch == ':')
{ {
/* This is the successful exit condition for the loop. */ /* This is the successful exit condition for the loop. */
if (gfc_next_char () == ':') if (gfc_next_ascii_char () == ':')
break; break;
} }
else if (ch == ',') else if (ch == ',')
{ {
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
switch (gfc_peek_char ()) switch (gfc_peek_ascii_char ())
{ {
case 'a': case 'a':
if (match_string_p ("allocatable")) if (match_string_p ("allocatable"))
...@@ -2809,7 +2811,7 @@ match_attr_spec (void) ...@@ -2809,7 +2811,7 @@ match_attr_spec (void)
case 'i': case 'i':
if (match_string_p ("int")) if (match_string_p ("int"))
{ {
ch = gfc_next_char (); ch = gfc_next_ascii_char ();
if (ch == 'e') if (ch == 'e')
{ {
if (match_string_p ("nt")) if (match_string_p ("nt"))
...@@ -2841,8 +2843,8 @@ match_attr_spec (void) ...@@ -2841,8 +2843,8 @@ match_attr_spec (void)
break; break;
case 'p': case 'p':
gfc_next_char (); gfc_next_ascii_char ();
switch (gfc_next_char ()) switch (gfc_next_ascii_char ())
{ {
case 'a': case 'a':
if (match_string_p ("rameter")) if (match_string_p ("rameter"))
...@@ -2861,7 +2863,7 @@ match_attr_spec (void) ...@@ -2861,7 +2863,7 @@ match_attr_spec (void)
break; break;
case 'r': case 'r':
ch = gfc_next_char (); ch = gfc_next_ascii_char ();
if (ch == 'i') if (ch == 'i')
{ {
if (match_string_p ("vate")) if (match_string_p ("vate"))
...@@ -2901,8 +2903,8 @@ match_attr_spec (void) ...@@ -2901,8 +2903,8 @@ match_attr_spec (void)
break; break;
case 'v': case 'v':
gfc_next_char (); gfc_next_ascii_char ();
ch = gfc_next_char (); ch = gfc_next_ascii_char ();
if (ch == 'a') if (ch == 'a')
{ {
if (match_string_p ("lue")) if (match_string_p ("lue"))
...@@ -3938,7 +3940,7 @@ gfc_match_suffix (gfc_symbol *sym, gfc_symbol **result) ...@@ -3938,7 +3940,7 @@ gfc_match_suffix (gfc_symbol *sym, gfc_symbol **result)
match is_bind_c; /* Found bind(c). */ match is_bind_c; /* Found bind(c). */
match is_result; /* Found result clause. */ match is_result; /* Found result clause. */
match found_match; /* Status of whether we've found a good match. */ match found_match; /* Status of whether we've found a good match. */
int peek_char; /* Character we're going to peek at. */ char peek_char; /* Character we're going to peek at. */
bool allow_binding_name; bool allow_binding_name;
/* Initialize to having found nothing. */ /* Initialize to having found nothing. */
...@@ -3948,7 +3950,7 @@ gfc_match_suffix (gfc_symbol *sym, gfc_symbol **result) ...@@ -3948,7 +3950,7 @@ gfc_match_suffix (gfc_symbol *sym, gfc_symbol **result)
/* Get the next char to narrow between result and bind(c). */ /* Get the next char to narrow between result and bind(c). */
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
peek_char = gfc_peek_char (); peek_char = gfc_peek_ascii_char ();
/* C binding names are not allowed for internal procedures. */ /* C binding names are not allowed for internal procedures. */
if (gfc_current_state () == COMP_CONTAINS if (gfc_current_state () == COMP_CONTAINS
...@@ -4037,7 +4039,7 @@ match_procedure_decl (void) ...@@ -4037,7 +4039,7 @@ match_procedure_decl (void)
/* Get the type spec. for the procedure interface. */ /* Get the type spec. for the procedure interface. */
old_loc = gfc_current_locus; old_loc = gfc_current_locus;
m = gfc_match_type_spec (&current_ts, 0); m = gfc_match_type_spec (&current_ts, 0);
if (m == MATCH_YES || (m == MATCH_NO && gfc_peek_char () == ')')) if (m == MATCH_YES || (m == MATCH_NO && gfc_peek_ascii_char () == ')'))
goto got_ts; goto got_ts;
if (m == MATCH_ERROR) if (m == MATCH_ERROR)
...@@ -4530,7 +4532,7 @@ gfc_match_entry (void) ...@@ -4530,7 +4532,7 @@ gfc_match_entry (void)
/* Check what next non-whitespace character is so we can tell if there /* Check what next non-whitespace character is so we can tell if there
is the required parens if we have a BIND(C). */ is the required parens if we have a BIND(C). */
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
peek_char = gfc_peek_char (); peek_char = gfc_peek_ascii_char ();
if (state == COMP_SUBROUTINE) if (state == COMP_SUBROUTINE)
{ {
...@@ -4686,7 +4688,7 @@ gfc_match_subroutine (void) ...@@ -4686,7 +4688,7 @@ gfc_match_subroutine (void)
/* Check what next non-whitespace character is so we can tell if there /* Check what next non-whitespace character is so we can tell if there
is the required parens if we have a BIND(C). */ is the required parens if we have a BIND(C). */
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
peek_char = gfc_peek_char (); peek_char = gfc_peek_ascii_char ();
if (gfc_add_subroutine (&sym->attr, sym->name, NULL) == FAILURE) if (gfc_add_subroutine (&sym->attr, sym->name, NULL) == FAILURE)
return MATCH_ERROR; return MATCH_ERROR;
...@@ -5486,7 +5488,7 @@ match ...@@ -5486,7 +5488,7 @@ match
gfc_match_pointer (void) gfc_match_pointer (void)
{ {
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
if (gfc_peek_char () == '(') if (gfc_peek_ascii_char () == '(')
{ {
if (!gfc_option.flag_cray_pointer) if (!gfc_option.flag_cray_pointer)
{ {
......
...@@ -156,6 +156,66 @@ error_integer (long int i) ...@@ -156,6 +156,66 @@ error_integer (long int i)
locus. Calls error_printf() recursively, but the recursion is at locus. Calls error_printf() recursively, but the recursion is at
most one level deep. */ most one level deep. */
static void
print_wide_char (gfc_char_t c)
{
static const char xdigit[16] = { '0', '1', '2', '3', '4', '5', '6',
'7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
char buf[9];
if (gfc_wide_is_printable (c))
error_char (c);
else if (c < ((gfc_char_t) 1 << 8))
{
buf[2] = '\0';
buf[1] = xdigit[c & 0x0F];
c = c >> 4;
buf[0] = xdigit[c & 0x0F];
error_char ('\\');
error_char ('x');
error_string (buf);
}
else if (c < ((gfc_char_t) 1 << 16))
{
buf[4] = '\0';
buf[3] = xdigit[c & 0x0F];
c = c >> 4;
buf[2] = xdigit[c & 0x0F];
c = c >> 4;
buf[1] = xdigit[c & 0x0F];
c = c >> 4;
buf[0] = xdigit[c & 0x0F];
error_char ('\\');
error_char ('u');
error_string (buf);
}
else
{
buf[8] = '\0';
buf[7] = xdigit[c & 0x0F];
c = c >> 4;
buf[6] = xdigit[c & 0x0F];
c = c >> 4;
buf[5] = xdigit[c & 0x0F];
c = c >> 4;
buf[4] = xdigit[c & 0x0F];
c = c >> 4;
buf[3] = xdigit[c & 0x0F];
c = c >> 4;
buf[2] = xdigit[c & 0x0F];
c = c >> 4;
buf[1] = xdigit[c & 0x0F];
c = c >> 4;
buf[0] = xdigit[c & 0x0F];
error_char ('\\');
error_char ('U');
error_string (buf);
}
}
static void error_printf (const char *, ...) ATTRIBUTE_GCC_GFC(1,2); static void error_printf (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
static void static void
...@@ -163,8 +223,8 @@ show_locus (locus *loc, int c1, int c2) ...@@ -163,8 +223,8 @@ show_locus (locus *loc, int c1, int c2)
{ {
gfc_linebuf *lb; gfc_linebuf *lb;
gfc_file *f; gfc_file *f;
char c, *p; gfc_char_t c, *p;
int i, m, offset, cmax; int i, offset, cmax;
/* TODO: Either limit the total length and number of included files /* TODO: Either limit the total length and number of included files
displayed or add buffering of arbitrary number of characters in displayed or add buffering of arbitrary number of characters in
...@@ -246,8 +306,8 @@ show_locus (locus *loc, int c1, int c2) ...@@ -246,8 +306,8 @@ show_locus (locus *loc, int c1, int c2)
to work correctly when nonprintable characters exist. A better to work correctly when nonprintable characters exist. A better
solution should be found. */ solution should be found. */
p = lb->line + offset; p = &(lb->line[offset]);
i = strlen (p); i = gfc_wide_strlen (p);
if (i > terminal_width) if (i > terminal_width)
i = terminal_width - 1; i = terminal_width - 1;
...@@ -257,23 +317,7 @@ show_locus (locus *loc, int c1, int c2) ...@@ -257,23 +317,7 @@ show_locus (locus *loc, int c1, int c2)
if (c == '\t') if (c == '\t')
c = ' '; c = ' ';
if (ISPRINT (c)) print_wide_char (c);
error_char (c);
else
{
error_char ('\\');
error_char ('x');
m = ((c >> 4) & 0x0F) + '0';
if (m > '9')
m += 'A' - '9' - 1;
error_char (m);
m = (c & 0x0F) + '0';
if (m > '9')
m += 'A' - '9' - 1;
error_char (m);
}
} }
error_char ('\n'); error_char ('\n');
......
...@@ -700,6 +700,21 @@ typedef struct ...@@ -700,6 +700,21 @@ typedef struct
symbol_attribute; symbol_attribute;
/* We need to store source lines as sequences of multibyte source
characters. We define here a type wide enough to hold any multibyte
source character, just like libcpp does. A 32-bit type is enough. */
#if HOST_BITS_PER_INT >= 32
typedef unsigned int gfc_char_t;
#elif HOST_BITS_PER_LONG >= 32
typedef unsigned long gfc_char_t;
#elif defined(HAVE_LONG_LONG) && (HOST_BITS_PER_LONGLONG >= 32)
typedef unsigned long long gfc_char_t;
#else
# error "Cannot find an integer type with at least 32 bits"
#endif
/* The following three structures are used to identify a location in /* The following three structures are used to identify a location in
the sources. the sources.
...@@ -729,7 +744,7 @@ typedef struct gfc_linebuf ...@@ -729,7 +744,7 @@ typedef struct gfc_linebuf
int truncated; int truncated;
bool dbg_emitted; bool dbg_emitted;
char line[1]; gfc_char_t line[1];
} gfc_linebuf; } gfc_linebuf;
#define gfc_linebuf_header_size (offsetof (gfc_linebuf, line)) #define gfc_linebuf_header_size (offsetof (gfc_linebuf, line))
...@@ -738,7 +753,7 @@ typedef struct gfc_linebuf ...@@ -738,7 +753,7 @@ typedef struct gfc_linebuf
typedef struct typedef struct
{ {
char *nextc; gfc_char_t *nextc;
gfc_linebuf *lb; gfc_linebuf *lb;
} locus; } locus;
...@@ -1940,10 +1955,18 @@ void gfc_advance_line (void); ...@@ -1940,10 +1955,18 @@ void gfc_advance_line (void);
int gfc_check_include (void); int gfc_check_include (void);
int gfc_define_undef_line (void); int gfc_define_undef_line (void);
int gfc_wide_is_printable (gfc_char_t);
int gfc_wide_is_digit (gfc_char_t);
int gfc_wide_fits_in_byte (gfc_char_t);
gfc_char_t gfc_wide_tolower (gfc_char_t);
size_t gfc_wide_strlen (const gfc_char_t *);
void gfc_skip_comments (void); void gfc_skip_comments (void);
int gfc_next_char_literal (int); gfc_char_t gfc_next_char_literal (int);
int gfc_next_char (void); gfc_char_t gfc_next_char (void);
int gfc_peek_char (void); char gfc_next_ascii_char (void);
gfc_char_t gfc_peek_char (void);
char gfc_peek_ascii_char (void);
void gfc_error_recovery (void); void gfc_error_recovery (void);
void gfc_gobble_whitespace (void); void gfc_gobble_whitespace (void);
try gfc_new_file (void); try gfc_new_file (void);
...@@ -2354,6 +2377,7 @@ bool gfc_check_access (gfc_access, gfc_access); ...@@ -2354,6 +2377,7 @@ bool gfc_check_access (gfc_access, gfc_access);
symbol_attribute gfc_variable_attr (gfc_expr *, gfc_typespec *); symbol_attribute gfc_variable_attr (gfc_expr *, gfc_typespec *);
symbol_attribute gfc_expr_attr (gfc_expr *); symbol_attribute gfc_expr_attr (gfc_expr *);
match gfc_match_rvalue (gfc_expr **); match gfc_match_rvalue (gfc_expr **);
int gfc_check_digit (char, int);
/* trans.c */ /* trans.c */
void gfc_generate_code (gfc_namespace *); void gfc_generate_code (gfc_namespace *);
......
...@@ -237,13 +237,17 @@ Allow @samp{$} as a valid character in a symbol name. ...@@ -237,13 +237,17 @@ Allow @samp{$} as a valid character in a symbol name.
@opindex @code{backslash} @opindex @code{backslash}
@cindex backslash @cindex backslash
@cindex escape characters @cindex escape characters
Change the interpretation of backslashes in string literals Change the interpretation of backslashes in string literals from a single
from a single backslash character to ``C-style'' escape characters. backslash character to ``C-style'' escape characters. The following
The following combinations are expanded \a, \b, \f, \n, \r, \t, combinations are expanded @code{\a}, @code{\b}, @code{\f}, @code{\n},
\v, \\, and \0 to the ASCII characters alert, backspace, form feed, @code{\r}, @code{\t}, @code{\v}, @code{\\}, and @code{\0} to the ASCII
newline, carriage return, horizontal tab, vertical tab, backslash, characters alert, backspace, form feed, newline, carriage return,
and NUL, respectively. All other combinations of a character preceded horizontal tab, vertical tab, backslash, and NUL, respectively.
by \ are unexpanded. Additionally, @code{\x}@var{nn}, @code{\u}@var{nnnn} and
@code{\U}@var{nnnnnnnn} (where each @var{n} is a hexadecimal digit) are
translated into the Unicode characters corresponding to the specified code
points. All other combinations of a character preceded by \ are
unexpanded.
@item -fmodule-private @item -fmodule-private
@opindex @code{fmodule-private} @opindex @code{fmodule-private}
......
...@@ -132,7 +132,7 @@ mode; ...@@ -132,7 +132,7 @@ mode;
static char static char
next_char (int in_string) next_char (int in_string)
{ {
static char c; static gfc_char_t c;
if (use_last_char) if (use_last_char)
{ {
...@@ -153,18 +153,11 @@ next_char (int in_string) ...@@ -153,18 +153,11 @@ next_char (int in_string)
if (gfc_option.flag_backslash && c == '\\') if (gfc_option.flag_backslash && c == '\\')
{ {
int tmp;
locus old_locus = gfc_current_locus; locus old_locus = gfc_current_locus;
/* Use a temp variable to avoid side effects from gfc_match_special_char if (gfc_match_special_char (&c) == MATCH_NO)
since it uses an int * for its argument. */
tmp = (int)c;
if (gfc_match_special_char (&tmp) == MATCH_NO)
gfc_current_locus = old_locus; gfc_current_locus = old_locus;
c = (char)tmp;
if (!(gfc_option.allow_std & GFC_STD_GNU) && !inhibit_warnings) if (!(gfc_option.allow_std & GFC_STD_GNU) && !inhibit_warnings)
gfc_warning ("Extension: backslash character at %C"); gfc_warning ("Extension: backslash character at %C");
} }
...@@ -172,7 +165,7 @@ next_char (int in_string) ...@@ -172,7 +165,7 @@ next_char (int in_string)
if (mode == MODE_COPY) if (mode == MODE_COPY)
*format_string++ = c; *format_string++ = c;
c = TOUPPER (c); c = TOUPPER ((unsigned char) c);
return c; return c;
} }
...@@ -3185,7 +3178,7 @@ match_io (io_kind k) ...@@ -3185,7 +3178,7 @@ match_io (io_kind k)
char name[GFC_MAX_SYMBOL_LEN + 1]; char name[GFC_MAX_SYMBOL_LEN + 1];
gfc_code *io_code; gfc_code *io_code;
gfc_symbol *sym; gfc_symbol *sym;
int comma_flag, c; int comma_flag;
locus where; locus where;
locus spec_end; locus spec_end;
gfc_dt *dt; gfc_dt *dt;
...@@ -3203,7 +3196,7 @@ match_io (io_kind k) ...@@ -3203,7 +3196,7 @@ match_io (io_kind k)
else if (k == M_PRINT) else if (k == M_PRINT)
{ {
/* Treat the non-standard case of PRINT namelist. */ /* Treat the non-standard case of PRINT namelist. */
if ((gfc_current_form == FORM_FIXED || gfc_peek_char () == ' ') if ((gfc_current_form == FORM_FIXED || gfc_peek_ascii_char () == ' ')
&& gfc_match_name (name) == MATCH_YES) && gfc_match_name (name) == MATCH_YES)
{ {
gfc_find_symbol (name, NULL, 1, &sym); gfc_find_symbol (name, NULL, 1, &sym);
...@@ -3227,7 +3220,7 @@ match_io (io_kind k) ...@@ -3227,7 +3220,7 @@ match_io (io_kind k)
if (gfc_current_form == FORM_FREE) if (gfc_current_form == FORM_FREE)
{ {
c = gfc_peek_char(); char c = gfc_peek_ascii_char ();
if (c != ' ' && c != '*' && c != '\'' && c != '"') if (c != ' ' && c != '*' && c != '\'' && c != '"')
{ {
m = MATCH_NO; m = MATCH_NO;
......
...@@ -38,7 +38,7 @@ extern gfc_st_label *gfc_statement_label; ...@@ -38,7 +38,7 @@ extern gfc_st_label *gfc_statement_label;
/* match.c. */ /* match.c. */
/* Generic match subroutines. */ /* Generic match subroutines. */
match gfc_match_special_char (int *); match gfc_match_special_char (gfc_char_t *);
match gfc_match_space (void); match gfc_match_space (void);
match gfc_match_eos (void); match gfc_match_eos (void);
match gfc_match_small_literal_int (int *, int *); match gfc_match_small_literal_int (int *, int *);
......
...@@ -36,17 +36,17 @@ match ...@@ -36,17 +36,17 @@ match
gfc_match_omp_eos (void) gfc_match_omp_eos (void)
{ {
locus old_loc; locus old_loc;
int c; char c;
old_loc = gfc_current_locus; old_loc = gfc_current_locus;
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c = gfc_next_char (); c = gfc_next_ascii_char ();
switch (c) switch (c)
{ {
case '!': case '!':
do do
c = gfc_next_char (); c = gfc_next_ascii_char ();
while (c != '\n'); while (c != '\n');
/* Fall through */ /* Fall through */
......
...@@ -100,7 +100,7 @@ decode_specification_statement (void) ...@@ -100,7 +100,7 @@ decode_specification_statement (void)
{ {
gfc_statement st; gfc_statement st;
locus old_locus; locus old_locus;
int c; char c;
if (gfc_match_eos () == MATCH_YES) if (gfc_match_eos () == MATCH_YES)
return ST_NONE; return ST_NONE;
...@@ -121,7 +121,7 @@ decode_specification_statement (void) ...@@ -121,7 +121,7 @@ decode_specification_statement (void)
statement, we eliminate most possibilities by peeking at the statement, we eliminate most possibilities by peeking at the
first character. */ first character. */
c = gfc_peek_char (); c = gfc_peek_ascii_char ();
switch (c) switch (c)
{ {
...@@ -229,7 +229,7 @@ decode_statement (void) ...@@ -229,7 +229,7 @@ decode_statement (void)
gfc_statement st; gfc_statement st;
locus old_locus; locus old_locus;
match m; match m;
int c; char c;
#ifdef GFC_DEBUG #ifdef GFC_DEBUG
gfc_symbol_state (); gfc_symbol_state ();
...@@ -315,7 +315,7 @@ decode_statement (void) ...@@ -315,7 +315,7 @@ decode_statement (void)
statement, we eliminate most possibilities by peeking at the statement, we eliminate most possibilities by peeking at the
first character. */ first character. */
c = gfc_peek_char (); c = gfc_peek_ascii_char ();
switch (c) switch (c)
{ {
...@@ -462,7 +462,7 @@ static gfc_statement ...@@ -462,7 +462,7 @@ static gfc_statement
decode_omp_directive (void) decode_omp_directive (void)
{ {
locus old_locus; locus old_locus;
int c; char c;
#ifdef GFC_DEBUG #ifdef GFC_DEBUG
gfc_symbol_state (); gfc_symbol_state ();
...@@ -485,7 +485,7 @@ decode_omp_directive (void) ...@@ -485,7 +485,7 @@ decode_omp_directive (void)
statement, we eliminate most possibilities by peeking at the statement, we eliminate most possibilities by peeking at the
first character. */ first character. */
c = gfc_peek_char (); c = gfc_peek_ascii_char ();
switch (c) switch (c)
{ {
...@@ -569,31 +569,34 @@ static gfc_statement ...@@ -569,31 +569,34 @@ static gfc_statement
next_free (void) next_free (void)
{ {
match m; match m;
int c, d, cnt, at_bol; int i, cnt, at_bol;
char c;
at_bol = gfc_at_bol (); at_bol = gfc_at_bol ();
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
c = gfc_peek_char (); c = gfc_peek_ascii_char ();
if (ISDIGIT (c)) if (ISDIGIT (c))
{ {
char d;
/* Found a statement label? */ /* Found a statement label? */
m = gfc_match_st_label (&gfc_statement_label); m = gfc_match_st_label (&gfc_statement_label);
d = gfc_peek_char (); d = gfc_peek_ascii_char ();
if (m != MATCH_YES || !gfc_is_whitespace (d)) if (m != MATCH_YES || !gfc_is_whitespace (d))
{ {
gfc_match_small_literal_int (&c, &cnt); gfc_match_small_literal_int (&i, &cnt);
if (cnt > 5) if (cnt > 5)
gfc_error_now ("Too many digits in statement label at %C"); gfc_error_now ("Too many digits in statement label at %C");
if (c == 0) if (i == 0)
gfc_error_now ("Zero is not a valid statement label at %C"); gfc_error_now ("Zero is not a valid statement label at %C");
do do
c = gfc_next_char (); c = gfc_next_ascii_char ();
while (ISDIGIT(c)); while (ISDIGIT(c));
if (!gfc_is_whitespace (c)) if (!gfc_is_whitespace (c))
...@@ -607,11 +610,11 @@ next_free (void) ...@@ -607,11 +610,11 @@ next_free (void)
gfc_gobble_whitespace (); gfc_gobble_whitespace ();
if (at_bol && gfc_peek_char () == ';') if (at_bol && gfc_peek_ascii_char () == ';')
{ {
gfc_error_now ("Semicolon at %C needs to be preceded by " gfc_error_now ("Semicolon at %C needs to be preceded by "
"statement"); "statement");
gfc_next_char (); /* Eat up the semicolon. */ gfc_next_ascii_char (); /* Eat up the semicolon. */
return ST_NONE; return ST_NONE;
} }
...@@ -633,8 +636,8 @@ next_free (void) ...@@ -633,8 +636,8 @@ next_free (void)
{ {
int i; int i;
c = gfc_next_char (); c = gfc_next_ascii_char ();
for (i = 0; i < 5; i++, c = gfc_next_char ()) for (i = 0; i < 5; i++, c = gfc_next_ascii_char ())
gcc_assert (c == "!$omp"[i]); gcc_assert (c == "!$omp"[i]);
gcc_assert (c == ' '); gcc_assert (c == ' ');
...@@ -646,7 +649,7 @@ next_free (void) ...@@ -646,7 +649,7 @@ next_free (void)
if (at_bol && c == ';') if (at_bol && c == ';')
{ {
gfc_error_now ("Semicolon at %C needs to be preceded by statement"); gfc_error_now ("Semicolon at %C needs to be preceded by statement");
gfc_next_char (); /* Eat up the semicolon. */ gfc_next_ascii_char (); /* Eat up the semicolon. */
return ST_NONE; return ST_NONE;
} }
...@@ -661,7 +664,7 @@ next_fixed (void) ...@@ -661,7 +664,7 @@ next_fixed (void)
{ {
int label, digit_flag, i; int label, digit_flag, i;
locus loc; locus loc;
char c; gfc_char_t c;
if (!gfc_at_bol ()) if (!gfc_at_bol ())
return decode_statement (); return decode_statement ();
...@@ -694,7 +697,7 @@ next_fixed (void) ...@@ -694,7 +697,7 @@ next_fixed (void)
case '7': case '7':
case '8': case '8':
case '9': case '9':
label = label * 10 + c - '0'; label = label * 10 + ((unsigned char) c - '0');
label_locus = gfc_current_locus; label_locus = gfc_current_locus;
digit_flag = 1; digit_flag = 1;
break; break;
...@@ -705,7 +708,7 @@ next_fixed (void) ...@@ -705,7 +708,7 @@ next_fixed (void)
if (gfc_option.flag_openmp) if (gfc_option.flag_openmp)
{ {
for (i = 0; i < 5; i++, c = gfc_next_char_literal (0)) for (i = 0; i < 5; i++, c = gfc_next_char_literal (0))
gcc_assert (TOLOWER (c) == "*$omp"[i]); gcc_assert ((char) gfc_wide_tolower (c) == "*$omp"[i]);
if (c != ' ' && c != '0') if (c != ' ' && c != '0')
{ {
......
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