diff options
author | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-24 16:12:39 +0000 |
---|---|---|
committer | phython <phython@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-24 16:12:39 +0000 |
commit | 8558f75a50829d87f6048b61dc8243db922f3052 (patch) | |
tree | e4794412d7cc3e3ae05e14d41b0e2caadc51bcb9 /gcc/treelang | |
parent | 4604248826213a6511d6a296aa0e301238442c0a (diff) | |
download | gcc-8558f75a50829d87f6048b61dc8243db922f3052.tar.gz |
2005-02-24 James A. Morrison <phython@gcc.gnu.org>
* parse.y: (function_prototype): Accept EXTERNAL_REFERENCE_STORAGE.
Move function parameters check from ...
(function): ...Here. Update call to tree_code_create_function_initial.
(function_invocation): Use expressions_with_commas_opt instead of
expressions_with_commas.
(expressions_with_commas_opt): New rule.
* treetree.c (tree_code_create_function_prototype): Create PARM_DECLs
for function parameters.
(tree_code_create_function_initial): Remove PARMS parameter.
Don't create PARM_DECLs for function parameters.
* treetree.h (tree_code_create_function_initial): Remove PARMS
parameter.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95501 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/treelang')
-rw-r--r-- | gcc/treelang/ChangeLog | 16 | ||||
-rw-r--r-- | gcc/treelang/parse.y | 37 | ||||
-rw-r--r-- | gcc/treelang/treetree.c | 83 | ||||
-rw-r--r-- | gcc/treelang/treetree.h | 7 |
4 files changed, 79 insertions, 64 deletions
diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog index eb09cccdc85..6d05ce1c9b9 100644 --- a/gcc/treelang/ChangeLog +++ b/gcc/treelang/ChangeLog @@ -1,3 +1,19 @@ +2005-02-24 James A. Morrison <phython@gcc.gnu.org> + + PR other/19897 + * parse.y: (function_prototype): Accept EXTERNAL_REFERENCE_STORAGE. + Move function parameters check from ... + (function): ...Here. Update call to tree_code_create_function_initial. + (function_invocation): Use expressions_with_commas_opt instead of + expressions_with_commas. + (expressions_with_commas_opt): New rule. + * treetree.c (tree_code_create_function_prototype): Create PARM_DECLs + for function parameters. + (tree_code_create_function_initial): Remove PARMS parameter. + Don't create PARM_DECLs for function parameters. + * treetree.h (tree_code_create_function_initial): Remove PARMS + parameter. + 2005-02-23 Kazu Hirata <kazu@cs.umass.edu> * parse.y: Update copyright. diff --git a/gcc/treelang/parse.y b/gcc/treelang/parse.y index be8c02e79da..7ee71ec5a9c 100644 --- a/gcc/treelang/parse.y +++ b/gcc/treelang/parse.y @@ -273,6 +273,7 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO { case STATIC_STORAGE: case EXTERNAL_DEFINITION_STORAGE: + case EXTERNAL_REFERENCE_STORAGE: break; case AUTOMATIC_STORAGE: @@ -324,6 +325,17 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO STORAGE_CLASS (prod), NUMERIC_TYPE (type), first_parms, tok->tp.tok.location); + +#ifdef ENABLE_CHECKING + /* Check all the parameters have code. */ + for (this_parm = PARAMETERS (prod); + this_parm; + this_parm = this_parm->tp.pro.next) + { + gcc_assert ((struct prod_token_parm_item*)VARIABLE (this_parm)); + gcc_assert (((struct prod_token_parm_item*)VARIABLE (this_parm))->tp.pro.code); + } +#endif } ; @@ -332,7 +344,6 @@ NAME LEFT_BRACE { struct prod_token_parm_item *proto; struct prod_token_parm_item search_prod; struct prod_token_parm_item* tok; - struct prod_token_parm_item *this_parm; tok = $1; SYMBOL_TABLE_NAME ((&search_prod)) = tok; search_prod.category = token_category; @@ -346,20 +357,9 @@ NAME LEFT_BRACE { gcc_assert (proto->tp.pro.code); - tree_code_create_function_initial (proto->tp.pro.code, tok->tp.tok.location, - FIRST_PARMS (current_function)); - -#ifdef ENABLE_CHECKING - /* Check all the parameters have code. */ - for (this_parm = PARAMETERS (proto); - this_parm; - this_parm = this_parm->tp.pro.next) - { - gcc_assert ((struct prod_token_parm_item*)VARIABLE (this_parm)); - gcc_assert (((struct prod_token_parm_item*)VARIABLE (this_parm))->tp.pro.code); - } -#endif + tree_code_create_function_initial (proto->tp.pro.code, tok->tp.tok.location); } + variable_defs_opt statements_opt RIGHT_BRACE { struct prod_token_parm_item* tok; tok = $1; @@ -610,7 +610,7 @@ INTEGER { ; function_invocation: -NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS { +NAME LEFT_PARENTHESIS expressions_with_commas_opt RIGHT_PARENTHESIS { struct prod_token_parm_item *prod; struct prod_token_parm_item* tok; struct prod_token_parm_item search_prod; @@ -677,6 +677,13 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS { } ; +expressions_with_commas_opt: +/* Nil. */ { +$$ = 0 +} +|expressions_with_commas { $$ = $1 } +; + expressions_with_commas: expression { struct prod_token_parm_item *exp; diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c index 546969225d6..73dab2d290e 100644 --- a/gcc/treelang/treetree.c +++ b/gcc/treelang/treetree.c @@ -325,6 +325,7 @@ tree_code_create_function_prototype (unsigned char* chars, tree type_node; tree fn_type; tree fn_decl; + tree parm_list = NULL_TREE; /* Build the type. */ id = get_identifier ((const char*)chars); @@ -378,6 +379,37 @@ tree_code_create_function_prototype (unsigned char* chars, gcc_unreachable (); } + /* Make the argument variable decls. */ + for (parm = parms; parm; parm = parm->tp.par.next) + { + tree parm_decl = build_decl (PARM_DECL, get_identifier + ((const char*) (parm->tp.par.variable_name)), + tree_code_get_type (parm->type)); + + /* Some languages have different nominal and real types. */ + DECL_ARG_TYPE (parm_decl) = TREE_TYPE (parm_decl); + gcc_assert (DECL_ARG_TYPE (parm_decl)); + gcc_assert (fn_decl); + DECL_CONTEXT (parm_decl) = fn_decl; + DECL_SOURCE_LOCATION (parm_decl) = loc; + parm_list = chainon (parm_decl, parm_list); + } + + /* Back into reverse order as the back end likes them. */ + parm_list = nreverse (parm_list); + + DECL_ARGUMENTS (fn_decl) = parm_list; + + /* Save the decls for use when the args are referred to. */ + for (parm = parms; parm_list; + parm_list = TREE_CHAIN (parm_list), + parm = parm->tp.par.next) + { + gcc_assert (parm); /* Too few. */ + *parm->tp.par.where_to_put_var_tree = parm_list; + } + gcc_assert (!parm); /* Too many. */ + /* Process declaration of function defined elsewhere. */ rest_of_decl_compilation (fn_decl, 1, 0); @@ -386,21 +418,16 @@ tree_code_create_function_prototype (unsigned char* chars, /* Output code for start of function; the decl of the function is in - PREV_SAVED (as created by tree_code_create_function_prototype), - the function is at line number LINENO in file FILENAME. The - parameter details are in the lists PARMS. Returns nothing. */ + PREV_SAVED (as created by tree_code_create_function_prototype), + the function is at line number LINENO in file FILENAME. The + parameter details are in the lists PARMS. Returns nothing. */ + void tree_code_create_function_initial (tree prev_saved, - location_t loc, - struct prod_token_parm_item* parms) + location_t loc) { tree fn_decl; - tree param_decl; - tree parm_decl; - tree parm_list; tree resultdecl; - struct prod_token_parm_item* this_parm; - struct prod_token_parm_item* parm; fn_decl = prev_saved; gcc_assert (fn_decl); @@ -426,40 +453,6 @@ tree_code_create_function_initial (tree prev_saved, DECL_SOURCE_LOCATION (resultdecl) = loc; DECL_RESULT (fn_decl) = resultdecl; - /* Make the argument variable decls. */ - parm_list = NULL_TREE; - for (parm = parms; parm; parm = parm->tp.par.next) - { - parm_decl = build_decl (PARM_DECL, get_identifier - ((const char*) (parm->tp.par.variable_name)), - tree_code_get_type (parm->type)); - - /* Some languages have different nominal and real types. */ - DECL_ARG_TYPE (parm_decl) = TREE_TYPE (parm_decl); - gcc_assert (DECL_ARG_TYPE (parm_decl)); - gcc_assert (fn_decl); - DECL_CONTEXT (parm_decl) = fn_decl; - DECL_SOURCE_LOCATION (parm_decl) = loc; - parm_list = chainon (parm_decl, parm_list); - } - - /* Back into reverse order as the back end likes them. */ - parm_list = nreverse (parm_list); - - DECL_ARGUMENTS (fn_decl) = parm_list; - - /* Save the decls for use when the args are referred to. */ - for (param_decl = DECL_ARGUMENTS (fn_decl), - this_parm = parms; - param_decl; - param_decl = TREE_CHAIN (param_decl), - this_parm = this_parm->tp.par.next) - { - gcc_assert (this_parm); /* Too few. */ - *this_parm->tp.par.where_to_put_var_tree = param_decl; - } - gcc_assert (!this_parm); /* Too many. */ - /* Create a new level at the start of the function. */ pushlevel (0); @@ -721,7 +714,7 @@ tree_code_get_expression (unsigned int exp_type, break; case EXP_FUNCTION_INVOCATION: - gcc_assert (op1 && op2); + gcc_assert (op1); { tree fun_ptr; fun_ptr = fold (build1 (ADDR_EXPR, diff --git a/gcc/treelang/treetree.h b/gcc/treelang/treetree.h index 41ce452b6ab..323509cf669 100644 --- a/gcc/treelang/treetree.h +++ b/gcc/treelang/treetree.h @@ -36,14 +36,13 @@ void tree_ggc_storage_always_used (void *m); tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree op2, tree op3); tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1); void tree_code_create_function_initial (tree prev_saved, - location_t loc, - struct prod_token_parm_item* parms); + location_t loc); void tree_code_create_function_wrapup (location_t loc); tree tree_code_create_function_prototype (unsigned char* chars, unsigned int storage_class, unsigned int ret_type, - struct prod_token_parm_item* parms, - location_t loc); + struct prod_token_parm_item* parms, + location_t loc); tree tree_code_create_variable (unsigned int storage_class, unsigned char* chars, unsigned int length, |