/* Lexical analyzer for C and Objective C.
- Copyright (C) 1987, 88, 89, 92, 94-96, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1987, 88, 89, 92, 94-97, 1998 Free Software Foundation, Inc.
This file is part of GNU CC.
Boston, MA 02111-1307, USA. */
#include "config.h"
-
-#include <stdio.h>
-#include <errno.h>
+#include "system.h"
#include <setjmp.h>
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
#include "rtl.h"
#include "tree.h"
#include "flags.h"
#include "c-parse.h"
#include "c-pragma.h"
-
-#include <ctype.h>
+#include "toplev.h"
/* MULTIBYTE_CHARS support only works for native compilers.
??? Ideally what we want is to model widechar support after
#endif
#ifdef MULTIBYTE_CHARS
-#include <stdlib.h>
#include <locale.h>
#endif
-#ifndef errno
-extern int errno;
-#endif
-
#if USE_CPPLIB
#include "cpplib.h"
cpp_reader parse_in;
cpp_options parse_options;
static enum cpp_token cpp_token;
+#else
+/* Stream for reading from the input file. */
+FILE *finput;
#endif
/* The elements of `ridpointers' are identifier nodes
int doing_objc_thang;
-extern tree is_class_name ();
-
extern int yydebug;
/* File used for outputting assembler code. */
#ifdef HANDLE_SYSV_PRAGMA
static int handle_sysv_pragma PROTO((int));
#endif /* HANDLE_SYSV_PRAGMA */
+static int whitespace_cr PROTO((int));
static int skip_white_space PROTO((int));
+static int skip_white_space_on_line PROTO((void));
static char *extend_token_buffer PROTO((char *));
static int readescape PROTO((int *));
int check_newline ();
wordlist[i].name = "oneway";
}
\f
-#if USE_CPPLIB
-void
+char *
init_parse (filename)
char *filename;
{
+#if !USE_CPPLIB
+ /* Open input file. */
+ if (filename == 0 || !strcmp (filename, "-"))
+ {
+ finput = stdin;
+ filename = "stdin";
+ }
+ else
+ finput = fopen (filename, "r");
+ if (finput == 0)
+ pfatal_with_name (filename);
+
+#ifdef IO_BUFFER_SIZE
+ setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
+#endif
+#endif /* !USE_CPPLIB */
+
init_lex ();
+
+#if USE_CPPLIB
yy_cur = "\n";
yy_lim = yy_cur+1;
parse_in.show_column = 1;
if (! cpp_start_read (&parse_in, filename))
abort ();
+#endif
+
+ return filename;
}
void
finish_parse ()
{
+#if USE_CPPLIB
cpp_finish (&parse_in);
-}
+#else
+ fclose (finput);
#endif
+}
void
init_lex ()
\f
/* Iff C is a carriage return, warn about it - if appropriate -
and return nonzero. */
-int
+static int
whitespace_cr (c)
int c;
{
if (floatflag != NOT_FLOAT)
{
tree type = double_type_node;
- int exceeds_double = 0;
int imag = 0;
+ int conversion_errno = 0;
REAL_VALUE_TYPE value;
jmp_buf handler;
}
*p = 0;
- errno = 0;
/* Convert string to a double, checking for overflow. */
if (setjmp (handler))
error ("both `f' and `l' in floating constant");
type = float_type_node;
+ errno = 0;
value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
+ conversion_errno = errno;
/* A diagnostic is required here by some ANSI C testsuites.
This is not pedwarn, become some people don't want
an error for this. */
else if (lflag)
{
type = long_double_type_node;
+ errno = 0;
value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
+ conversion_errno = errno;
if (REAL_VALUE_ISINF (value) && pedantic)
warning ("floating point number exceeds range of `long double'");
}
else
{
+ errno = 0;
value = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
+ conversion_errno = errno;
if (REAL_VALUE_ISINF (value) && pedantic)
warning ("floating point number exceeds range of `double'");
}
set_float_handler (NULL_PTR);
}
#ifdef ERANGE
- if (errno == ERANGE && !flag_traditional && pedantic)
- {
- /* ERANGE is also reported for underflow,
- so test the value to distinguish overflow from that. */
- if (REAL_VALUES_LESS (dconst1, value)
- || REAL_VALUES_LESS (value, dconstm1))
- {
- warning ("floating point number exceeds range of `double'");
- exceeds_double = 1;
- }
- }
+ /* ERANGE is also reported for underflow,
+ so test the value to distinguish overflow from that. */
+ if (conversion_errno == ERANGE && !flag_traditional && pedantic
+ && (REAL_VALUES_LESS (dconst1, value)
+ || REAL_VALUES_LESS (value, dconstm1)))
+ warning ("floating point number exceeds range of `double'");
#endif
/* If the result is not a number, assume it must have been
int spec_imag = 0;
int bytes, warn, i;
+ traditional_type = ansi_type = type = NULL_TREE;
while (1)
{
if (c == 'u' || c == 'U')