diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2000-06-19 22:28:28 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-06-19 22:28:28 +0000 |
commit | 7e585d16ce4df23bfd21cf82e58dd323f9939232 (patch) | |
tree | f8653d51128340a6406078646bbab4019565ca16 /gcc/c-lex.c | |
parent | 2f1034940abd6330b54ba614df5cd1795fd76557 (diff) | |
download | gcc-7e585d16ce4df23bfd21cf82e58dd323f9939232.zip gcc-7e585d16ce4df23bfd21cf82e58dd323f9939232.tar.gz gcc-7e585d16ce4df23bfd21cf82e58dd323f9939232.tar.bz2 |
c-parse.in (undeclared_variable_notice): Moved to c-typeck.c.
* c-parse.in (undeclared_variable_notice): Moved to c-typeck.c.
(primary: IDENTIFIER): Just call build_external_ref.
* c-parse.y, c-parse.c, objc/objc-parse.y, objc/objc-parse.c:
Regenerate.
* c-lex.c (lastiddecl): Remove.
(yylex): Replace all instances of lastiddecl with local
variables.
* c-typeck.c (build_external_ref): New function. Treat decls
with C_DECL_ANTICIPATED mostly the same as nonexistent decls.
Look up the decl from the id here. Call lookup_objc_ivar.
* c-lang.c (lookup_objc_ivar): Stub.
* objc/objc-act.c (lookup_objc_ivar): New function.
* c-tree.h: Prototype lookup_objc_ivar and build_external_ref.
* c-lex.h: Don't declare lastiddecl.
From-SVN: r34602
Diffstat (limited to 'gcc/c-lex.c')
-rw-r--r-- | gcc/c-lex.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 2e6e5a9..41a88b0 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -126,12 +126,6 @@ put_back (ch) int linemode; -/* the declaration found for the last IDENTIFIER token read in. - yylex must look this up to detect typedefs, which get token type TYPENAME, - so it is left around in case the identifier is not a typedef but is - used in a context which makes it a reference to a variable. */ -tree lastiddecl; - extern int yydebug; /* File used for outputting assembler code. */ @@ -1400,10 +1394,10 @@ yylex () /* Only return OBJECTNAME if it is a typedef. */ if (doing_objc_thang && value == OBJECTNAME) { - lastiddecl = lookup_name(yylval.ttype); + tree decl = lookup_name(yylval.ttype); - if (lastiddecl == NULL_TREE - || TREE_CODE (lastiddecl) != TYPE_DECL) + if (decl == NULL_TREE + || TREE_CODE (decl) != TYPE_DECL) value = IDENTIFIER; } @@ -1422,24 +1416,26 @@ yylex () if (value == IDENTIFIER) { + tree decl; + if (token_buffer[0] == '@') error("invalid identifier `%s'", token_buffer); yylval.ttype = get_identifier (token_buffer); - lastiddecl = lookup_name (yylval.ttype); + decl = lookup_name (yylval.ttype); - if (lastiddecl != 0 && TREE_CODE (lastiddecl) == TYPE_DECL) + if (decl != 0 && TREE_CODE (decl) == TYPE_DECL) value = TYPENAME; /* A user-invisible read-only initialized variable should be replaced by its value. We handle only strings since that's the only case used in C. */ - else if (lastiddecl != 0 && TREE_CODE (lastiddecl) == VAR_DECL - && DECL_IGNORED_P (lastiddecl) - && TREE_READONLY (lastiddecl) - && DECL_INITIAL (lastiddecl) != 0 - && TREE_CODE (DECL_INITIAL (lastiddecl)) == STRING_CST) + else if (decl != 0 && TREE_CODE (decl) == VAR_DECL + && DECL_IGNORED_P (decl) + && TREE_READONLY (decl) + && DECL_INITIAL (decl) != 0 + && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST) { - tree stringval = DECL_INITIAL (lastiddecl); + tree stringval = DECL_INITIAL (decl); /* Copy the string value so that we won't clobber anything if we put something in the TREE_CHAIN of this one. */ |