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-parse.in | |
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-parse.in')
-rw-r--r-- | gcc/c-parse.in | 169 |
1 files changed, 3 insertions, 166 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index aa54751..7efe9cd 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -226,9 +226,6 @@ static tree prefix_attributes = NULL_TREE; /* Stack of saved values of current_declspecs and prefix_attributes. */ static tree declspec_stack; -/* 1 if we explained undeclared var errors. */ -static int undeclared_variable_notice; - /* For __extension__, save/restore the warning flags which are controlled by __extension__. */ #define SAVE_WARN_FLAGS() \ @@ -628,169 +625,9 @@ expr_no_commas: primary: IDENTIFIER { - $$ = lastiddecl; - if (!$$ || $$ == error_mark_node) - { - if (yychar == YYEMPTY) - yychar = YYLEX; - if (yychar == '(') - { -ifobjc - tree decl; - - if (objc_receiver_context - && ! (objc_receiver_context - && strcmp (IDENTIFIER_POINTER ($1), "super"))) - /* we have a message to super */ - $$ = get_super_receiver (); - else if (objc_method_context - && (decl = is_ivar (objc_ivar_chain, $1))) - { - if (is_private (decl)) - $$ = error_mark_node; - else - $$ = build_ivar_reference ($1); - } - else -end ifobjc - { - /* Ordinary implicit function declaration. */ - $$ = implicitly_declare ($1); - assemble_external ($$); - TREE_USED ($$) = 1; - } - } - else if (current_function_decl == 0) - { - error ("`%s' undeclared here (not in a function)", - IDENTIFIER_POINTER ($1)); - $$ = error_mark_node; - } - else - { -ifobjc - tree decl; - - if (objc_receiver_context - && ! strcmp (IDENTIFIER_POINTER ($1), "super")) - /* we have a message to super */ - $$ = get_super_receiver (); - else if (objc_method_context - && (decl = is_ivar (objc_ivar_chain, $1))) - { - if (is_private (decl)) - $$ = error_mark_node; - else - $$ = build_ivar_reference ($1); - } - else -end ifobjc - { - if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node - || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl) - { - error ("`%s' undeclared (first use in this function)", - IDENTIFIER_POINTER ($1)); - - if (! undeclared_variable_notice) - { - error ("(Each undeclared identifier is reported only once"); - error ("for each function it appears in.)"); - undeclared_variable_notice = 1; - } - } - $$ = error_mark_node; - /* Prevent repeated error messages. */ - IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node; - IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl; - } - } - } - else if (TREE_TYPE ($$) == error_mark_node) - $$ = error_mark_node; - else if (C_DECL_ANTICIPATED ($$)) - { - /* The first time we see a build-in function used, - if it has not been declared. */ - C_DECL_ANTICIPATED ($$) = 0; - if (yychar == YYEMPTY) - yychar = YYLEX; - if (yychar == '(') - { - /* Omit the implicit declaration we - would ordinarily do, so we don't lose - the actual built in type. - But print a diagnostic for the mismatch. */ -ifobjc - if (objc_method_context - && is_ivar (objc_ivar_chain, $1)) - error ("Instance variable `%s' implicitly declared as function", - IDENTIFIER_POINTER (DECL_NAME ($$))); - else -end ifobjc - if (TREE_CODE ($$) != FUNCTION_DECL) - error ("`%s' implicitly declared as function", - IDENTIFIER_POINTER (DECL_NAME ($$))); - else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$))) - != TYPE_MODE (integer_type_node)) - && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE ($$)))) - pedwarn ("type mismatch in implicit declaration for built-in function `%s'", - IDENTIFIER_POINTER (DECL_NAME ($$))); - /* If it really returns void, change that to int. */ - if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node) - TREE_TYPE ($$) - = build_function_type (integer_type_node, - TYPE_ARG_TYPES (TREE_TYPE ($$))); - } - else - pedwarn ("built-in function `%s' used without declaration", - IDENTIFIER_POINTER (DECL_NAME ($$))); - - /* Do what we would ordinarily do when a fn is used. */ - assemble_external ($$); - TREE_USED ($$) = 1; - } - else - { - assemble_external ($$); - TREE_USED ($$) = 1; -ifobjc - /* we have a definition - still check if iVariable */ - - if (!objc_receiver_context - || (objc_receiver_context - && strcmp (IDENTIFIER_POINTER ($1), "super"))) - { - tree decl; - - if (objc_method_context - && (decl = is_ivar (objc_ivar_chain, $1))) - { - if (IDENTIFIER_LOCAL_VALUE ($1)) - warning ("local declaration of `%s' hides instance variable", - IDENTIFIER_POINTER ($1)); - else - { - if (is_private (decl)) - $$ = error_mark_node; - else - $$ = build_ivar_reference ($1); - } - } - } - else /* we have a message to super */ - $$ = get_super_receiver (); -end ifobjc - } - - if (TREE_CODE ($$) == CONST_DECL) - { - $$ = DECL_INITIAL ($$); - /* This is to prevent an enum whose value is 0 - from being considered a null pointer constant. */ - $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$); - TREE_CONSTANT ($$) = 1; - } + if (yychar == YYEMPTY) + yychar = YYLEX; + $$ = build_external_ref ($1, yychar == '('); } | CONSTANT | string |