summaryrefslogtreecommitdiff
path: root/gcc/c-lex.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1997-11-02 21:19:36 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>1997-11-02 21:19:36 +0000
commit0dbd1c7442aeabc3e63daf6f70f8fb136f0cf38e (patch)
tree46fe768360493f03f7282d07762e7b26c292aabd /gcc/c-lex.c
parent638d2d6c66cb82345c84b92a46ebf9445c56204c (diff)
downloadgcc-0dbd1c7442aeabc3e63daf6f70f8fb136f0cf38e.tar.gz
Update mainline egcs to gcc2 snapshot 971021.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@16278 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r--gcc/c-lex.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index fd0dd90393a..bee6ce7059d 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -1,5 +1,5 @@
/* Lexical analyzer for C and Objective C.
- Copyright (C) 1987, 88, 89, 92, 94, 95, 1996 Free Software Foundation, Inc.
+ Copyright (C) 1987, 88, 89, 92, 94-96, 1997 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -18,12 +18,12 @@ along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include "config.h"
#include <stdio.h>
#include <errno.h>
#include <setjmp.h>
-#include "config.h"
#include "rtl.h"
#include "tree.h"
#include "input.h"
@@ -118,6 +118,8 @@ char *token_buffer; /* Pointer to token buffer.
Actual allocated length is maxtoken + 2.
This is not static because objc-parse.y uses it. */
+static int indent_level = 0; /* Number of { minus number of }. */
+
/* Nonzero if end-of-file has been seen on input. */
static int end_of_file;
@@ -747,6 +749,7 @@ linenum:
input_file_stack->line = old_lineno;
p->next = input_file_stack;
p->name = input_filename;
+ p->indent_level = indent_level;
input_file_stack = p;
input_file_stack_tick++;
debug_start_source_file (input_filename);
@@ -758,6 +761,14 @@ linenum:
if (input_file_stack->next)
{
struct file_stack *p = input_file_stack;
+ if (indent_level != p->indent_level)
+ {
+ warning_with_file_and_line
+ (p->name, old_lineno,
+ "This file contains more `%c's than `%c's.",
+ indent_level > p->indent_level ? '{' : '}',
+ indent_level > p->indent_level ? '}' : '{');
+ }
input_file_stack = p->next;
free (p);
input_file_stack_tick++;
@@ -816,6 +827,10 @@ linenum:
/* skip the rest of this line. */
skipline:
+#if !USE_CPPLIB
+ if (c != '\n' && c != EOF && nextchar >= 0)
+ c = nextchar, nextchar = -1;
+#endif
while (c != '\n' && c != EOF)
c = GETC();
return c;
@@ -1731,8 +1746,6 @@ yylex ()
else if (! spec_long_long)
ansi_type = long_unsigned_type_node;
else if (! spec_unsigned
- /* Verify value does not overflow into sign bit. */
- && TREE_INT_CST_HIGH (yylval.ttype) >= 0
&& int_fits_type_p (yylval.ttype,
long_long_integer_type_node))
ansi_type = long_long_integer_type_node;
@@ -2122,13 +2135,13 @@ yylex ()
break;
case '<':
if (c1 == '%')
- { value = '{'; goto done; }
+ { value = '{'; indent_level++; goto done; }
if (c1 == ':')
{ value = '['; goto done; }
break;
case '%':
if (c1 == '>')
- { value = '}'; goto done; }
+ { value = '}'; indent_level--; goto done; }
break;
}
UNGETC (c1);
@@ -2145,6 +2158,16 @@ yylex ()
value = 1;
break;
+ case '{':
+ indent_level++;
+ value = c;
+ break;
+
+ case '}':
+ indent_level--;
+ value = c;
+ break;
+
default:
value = c;
}