aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c57
1 files changed, 29 insertions, 28 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 358e5d1532b..bdcecc3efee 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -53,8 +53,8 @@ Boston, MA 02111-1307, USA. */
#define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ((ENV_VALUE) = getenv (ENV_NAME))
#endif
-/* The original file name, before changing "-" to "stdin". */
-static const char *orig_filename;
+/* The input filename as understood by CPP, where "" represents stdin. */
+static const char *cpp_filename;
/* We may keep statistics about how long which files took to compile. */
static int header_time, body_time;
@@ -102,8 +102,6 @@ init_c_lex (filename)
struct cpp_callbacks *cb;
struct c_fileinfo *toplevel;
- orig_filename = filename;
-
/* Set up filename timing. Must happen before cpp_start_read. */
file_info_tree = splay_tree_new ((splay_tree_compare_fn)strcmp,
0,
@@ -115,7 +113,7 @@ init_c_lex (filename)
body_time = get_run_time ();
toplevel->time = body_time;
}
-
+
#ifdef MULTIBYTE_CHARS
/* Change to the native locale for multibyte conversions. */
setlocale (LC_CTYPE, "");
@@ -136,8 +134,11 @@ init_c_lex (filename)
cb->undef = cb_undef;
}
+
if (filename == 0 || !strcmp (filename, "-"))
- filename = "stdin";
+ filename = "stdin", cpp_filename = "";
+ else
+ cpp_filename = filename;
/* Start it at 0. */
lineno = 0;
@@ -145,13 +146,13 @@ init_c_lex (filename)
return filename;
}
-/* A thin wrapper around the real parser that initializes the
+/* A thin wrapper around the real parser that initializes the
integrated preprocessor after debug output has been initialized. */
int
yyparse()
{
- if (! cpp_start_read (parse_in, orig_filename))
+ if (! cpp_start_read (parse_in, cpp_filename))
return 1; /* cpplib has emitted an error. */
return yyparse_1();
@@ -351,7 +352,7 @@ cb_undef (pfile, node)
/* Parse a '\uNNNN' or '\UNNNNNNNN' sequence.
- [lex.charset]: The character designated by the universal-character-name
+ [lex.charset]: The character designated by the universal-character-name
\UNNNNNNNN is that character whose character short name in ISO/IEC 10646
is NNNNNNNN; the character designated by the universal-character-name
\uNNNN is that character whose character short name in ISO/IEC 10646 is
@@ -549,7 +550,7 @@ readescape (p, limit, cptr)
warning ("the meaning of '\\%c' varies with -traditional", c);
return read_ucs (p, limit, cptr, c == 'u' ? 4 : 8);
-
+
case 'e': case 'E':
if (pedantic)
pedwarn ("non-ISO-standard escape sequence, '\\%c'", c);
@@ -600,7 +601,7 @@ is_extended_char (c)
error ("universal-character-name '\\U%08x' not valid in identifier", c);
return 1;
}
-
+
/* Latin */
if ((c >= 0x00c0 && c <= 0x00d6)
|| (c >= 0x00d8 && c <= 0x00f6)
@@ -914,7 +915,7 @@ struct pf_args
REAL_VALUE_TYPE value;
tree type;
};
-
+
static void
parse_float (data)
PTR data;
@@ -962,7 +963,7 @@ parse_float (data)
if (REAL_VALUE_ISINF (args->value) && pedantic)
warning ("floating point number exceeds range of '%s'", typename);
}
-
+
int
c_lex (value)
tree *value;
@@ -992,9 +993,9 @@ c_lex (value)
if (ISGRAPH (tok.val.c))
error ("stray '%c' in program", tok.val.c);
else
- error ("stray '\\%#o' in program", tok.val.c);
+ error ("stray '\\%o' in program", tok.val.c);
goto retry;
-
+
case CPP_NAME:
*value = get_identifier ((const char *)tok.val.node->name);
break;
@@ -1013,7 +1014,6 @@ c_lex (value)
case CPP_STRING:
case CPP_WSTRING:
- case CPP_OSTRING:
*value = lex_string ((const char *)tok.val.str.text,
tok.val.str.len, tok.type == CPP_WSTRING);
break;
@@ -1046,10 +1046,10 @@ lex_number (str, len)
tree value;
const char *p;
enum anon1 { NOT_FLOAT = 0, AFTER_POINT, AFTER_EXPON } floatflag = NOT_FLOAT;
-
+
/* We actually store only HOST_BITS_PER_CHAR bits in each part.
The code below which fills the parts array assumes that a host
- int is at least twice as wide as a host char, and that
+ int is at least twice as wide as a host char, and that
HOST_BITS_PER_WIDE_INT is an even multiple of HOST_BITS_PER_CHAR.
Two HOST_WIDE_INTs is the largest int literal we can store.
In order to detect overflow below, the number of parts (TOTAL_PARTS)
@@ -1057,7 +1057,7 @@ lex_number (str, len)
of two HOST_WIDE_INTs. */
#define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2)
unsigned int parts[TOTAL_PARTS];
-
+
/* Optimize for most frequent case. */
if (len == 1)
{
@@ -1093,9 +1093,7 @@ lex_number (str, len)
if (c == '.')
{
- if (base == 16 && pedantic && !flag_isoc99)
- pedwarn ("floating constant may not be in radix 16");
- else if (floatflag == AFTER_POINT)
+ if (floatflag == AFTER_POINT)
ERROR ("too many decimal points in floating constant");
else if (floatflag == AFTER_EXPON)
ERROR ("decimal point in exponent - impossible!");
@@ -1164,7 +1162,7 @@ lex_number (str, len)
}
/* If the highest-order part overflows (gets larger than
- a host char will hold) then the whole number has
+ a host char will hold) then the whole number has
overflowed. Record this and truncate the highest-order
part. */
if (parts[TOTAL_PARTS - 1] >> HOST_BITS_PER_CHAR)
@@ -1191,6 +1189,9 @@ lex_number (str, len)
struct pf_args args;
char *copy;
+ if (base == 16 && pedantic && !flag_isoc99)
+ pedwarn ("floating constant may not be in radix 16");
+
if (base == 16 && floatflag != AFTER_EXPON)
ERROR ("hexadecimal floating constant has no exponent");
@@ -1272,7 +1273,7 @@ lex_number (str, len)
/* Receive output from parse_float() */
conversion_errno = args.conversion_errno;
type = args.type;
-
+
#ifdef ERANGE
/* ERANGE is also reported for underflow,
so test the value to distinguish overflow from that. */
@@ -1394,9 +1395,9 @@ lex_number (str, len)
? long_unsigned_type_node
: long_integer_type_node);
else if (int_fits_type_p (value,
- spec_unsigned
+ spec_unsigned
? long_long_unsigned_type_node
- : long_long_integer_type_node))
+ : long_long_integer_type_node))
trad_type = (spec_unsigned
? long_long_unsigned_type_node
: long_long_integer_type_node);
@@ -1553,7 +1554,7 @@ lex_string (str, len, wide)
&& (unsigned) c >= ((unsigned)1 << width))
pedwarn ("escape sequence out of range for character");
}
-
+
/* Add this single character into the buffer either as a wchar_t
or as a single byte. */
if (wide)
@@ -1662,7 +1663,7 @@ lex_charconst (str, len, wide)
if (ISPRINT (c))
c = MAP_CHARACTER (c);
#endif
-
+
/* Merge character into result; ignore excess chars. */
num_chars += (width / TYPE_PRECISION (char_type_node));
if (num_chars < max_chars + 1)