PR fortran/46705
* gfortran.h: New enum gfc_instring.
(gfc_next_char_literal): Update prototype.
* scanner.c (gfc_next_char_literal): Use new enum. Only give missing
'&' warning for INSTRING_WARN. (gfc_next_char): Use new enum.
(gfc_gobble_whitespace): Likewise.
* io.c (next_char): Use new enum. (next_char_not_space): Likewise.
(format_lex): Likewise.
* match.c (gfc_match_parens): Likewise.
(gfc_match_special_char): Likewise. (gfc_match_name_C): Likewise.
* parse.c (next_fixed): Likewise.
* primary.c (match_hollerith_constant): Likewise.
(next_string_char): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167716
138bc75d-0d04-0410-961f-
82ee72b054a4
+2010-12-11 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR fortran/46705
+ * gfortran.h: New enum gfc_instring.
+ (gfc_next_char_literal): Update prototype.
+ * scanner.c (gfc_next_char_literal): Use new enum. Only give missing
+ '&' warning for INSTRING_WARN. (gfc_next_char): Use new enum.
+ (gfc_gobble_whitespace): Likewise.
+ * io.c (next_char): Use new enum. (next_char_not_space): Likewise.
+ (format_lex): Likewise.
+ * match.c (gfc_match_parens): Likewise.
+ (gfc_match_special_char): Likewise. (gfc_match_name_C): Likewise.
+ * parse.c (next_fixed): Likewise.
+ * primary.c (match_hollerith_constant): Likewise.
+ (next_string_char): Likewise.
+
2010-12-11 Tobias Burnus <burnus@net-b.de>
PR fortran/46370
{ SUCCESS = 1, FAILURE }
gfc_try;
+/* These are flags for identifying whether we are reading a character literal
+ between quotes or normal source code. */
+
+typedef enum
+{ NONSTRING = 0, INSTRING_WARN, INSTRING_NOWARN }
+gfc_instring;
+
/* This is returned by gfc_notification_std to know if, given the flags
that were given (-std=, -pedantic) we should issue an error, a warning
or nothing. */
{ MATCH_NO = 1, MATCH_YES, MATCH_ERROR }
match;
+/* Used for different Fortran source forms in places like scanner.c. */
typedef enum
{ FORM_FREE, FORM_FIXED, FORM_UNKNOWN }
gfc_source_form;
}
gfc_intrinsic_op;
-
/* This macro is the number of intrinsic operators that exist.
Assumptions are made about the numbering of the interface_op enums. */
#define GFC_INTRINSIC_OPS GFC_INTRINSIC_END
}
gfc_statement;
-
/* Types of interfaces that we can have. Assignment interfaces are
considered to be intrinsic operators. */
typedef enum
#define gfc_get_wide_string(n) XCNEWVEC (gfc_char_t, n)
void gfc_skip_comments (void);
-gfc_char_t gfc_next_char_literal (int);
+gfc_char_t gfc_next_char_literal (gfc_instring);
gfc_char_t gfc_next_char (void);
char gfc_next_ascii_char (void);
gfc_char_t gfc_peek_char (void);
/* Return the next character in the format string. */
static char
-next_char (int in_string)
+next_char (gfc_instring in_string)
{
static gfc_char_t c;
char c;
do
{
- error_element = c = next_char (0);
+ error_element = c = next_char (NONSTRING);
if (c == '\t')
{
if (gfc_option.allow_std & GFC_STD_GNU)
for (;;)
{
- c = next_char (1);
+ c = next_char (INSTRING_WARN);
if (c == '\0')
{
token = FMT_END;
if (c == delim)
{
- c = next_char (1);
+ c = next_char (INSTRING_NOWARN);
if (c == '\0')
{
{
while (repeat >0)
{
- next_char (1);
+ next_char (INSTRING_WARN);
repeat -- ;
}
}
gfc_match_parens (void)
{
locus old_loc, where;
- int count, instring;
+ int count;
+ gfc_instring instring;
gfc_char_t c, quote;
old_loc = gfc_current_locus;
count = 0;
- instring = 0;
+ instring = NONSTRING;
quote = ' ';
for (;;)
if (quote == ' ' && ((c == '\'') || (c == '"')))
{
quote = c;
- instring = 1;
+ instring = INSTRING_WARN;
continue;
}
if (quote != ' ' && c == quote)
{
quote = ' ';
- instring = 0;
+ instring = NONSTRING;
continue;
}
m = MATCH_YES;
- switch ((c = gfc_next_char_literal (1)))
+ switch ((c = gfc_next_char_literal (INSTRING_WARN)))
{
case 'a':
*res = '\a';
{
char buf[2] = { '\0', '\0' };
- c = gfc_next_char_literal (1);
+ c = gfc_next_char_literal (INSTRING_WARN);
if (!gfc_wide_fits_in_byte (c)
|| !gfc_check_digit ((unsigned char) c, 16))
return MATCH_NO;
/* Get the next char (first possible char of name) and see if
it's valid for C (either a letter or an underscore). */
- c = gfc_next_char_literal (1);
+ c = gfc_next_char_literal (INSTRING_WARN);
/* If the user put nothing expect spaces between the quotes, it is valid
and simply means there is no name= specifier and the name is the fortran
old_loc = gfc_current_locus;
/* Get next char; param means we're in a string. */
- c = gfc_next_char_literal (1);
+ c = gfc_next_char_literal (INSTRING_WARN);
} while (ISALNUM (c) || c == '_');
buffer[i] = '\0';
for (i = 0; i < 5; i++)
{
- c = gfc_next_char_literal (0);
+ c = gfc_next_char_literal (NONSTRING);
switch (c)
{
here, except for GCC attributes and OpenMP directives. */
case '*':
- c = gfc_next_char_literal (0);
+ c = gfc_next_char_literal (NONSTRING);
if (TOLOWER (c) == 'g')
{
- for (i = 0; i < 4; i++, c = gfc_next_char_literal (0))
+ for (i = 0; i < 4; i++, c = gfc_next_char_literal (NONSTRING))
gcc_assert (TOLOWER (c) == "gcc$"[i]);
return decode_gcc_attribute ();
}
else if (c == '$' && gfc_option.gfc_flag_openmp)
{
- for (i = 0; i < 4; i++, c = gfc_next_char_literal (0))
+ for (i = 0; i < 4; i++, c = gfc_next_char_literal (NONSTRING))
gcc_assert ((char) gfc_wide_tolower (c) == "$omp"[i]);
if (c != ' ' && c != '0')
of a previous statement. If we see something here besides a
space or zero, it must be a bad continuation line. */
- c = gfc_next_char_literal (0);
+ c = gfc_next_char_literal (NONSTRING);
if (c == '\n')
goto blank_line;
do
{
loc = gfc_current_locus;
- c = gfc_next_char_literal (0);
+ c = gfc_next_char_literal (NONSTRING);
}
while (gfc_is_whitespace (c));
for (i = 0; i < num; i++)
{
- gfc_char_t c = gfc_next_char_literal (1);
+ gfc_char_t c = gfc_next_char_literal (INSTRING_WARN);
if (! gfc_wide_fits_in_byte (c))
{
gfc_error ("Invalid Hollerith constant at %L contains a "
locus old_locus;
gfc_char_t c;
- c = gfc_next_char_literal (1);
+ c = gfc_next_char_literal (INSTRING_WARN);
*ret = 0;
if (c == '\n')
return c;
old_locus = gfc_current_locus;
- c = gfc_next_char_literal (0);
+ c = gfc_next_char_literal (NONSTRING);
if (c == delimiter)
return c;
context or not. */
gfc_char_t
-gfc_next_char_literal (int in_string)
+gfc_next_char_literal (gfc_instring in_string)
{
locus old_loc;
int i, prev_openmp_flag;
{
if (in_string)
{
- if (gfc_option.warn_ampersand)
- gfc_warning_now ("Missing '&' in continued character "
- "constant at %C");
gfc_current_locus.nextc--;
+ if (gfc_option.warn_ampersand && in_string == INSTRING_WARN)
+ gfc_warning ("Missing '&' in continued character "
+ "constant at %C");
}
/* Both !$omp and !$ -fopenmp continuation lines have & on the
continuation line only optionally. */
do
{
- c = gfc_next_char_literal (0);
+ c = gfc_next_char_literal (NONSTRING);
}
while (gfc_current_form == FORM_FIXED && gfc_is_whitespace (c));
do
{
old_loc = gfc_current_locus;
- c = gfc_next_char_literal (0);
+ c = gfc_next_char_literal (NONSTRING);
/* Issue a warning for nonconforming tabs. We keep track of the line
number because the Fortran matchers will often back up and the same
line will be scanned multiple times. */