Commit a10d44d9 by James A. Morrison

parse.y: (function_prototype): Accept EXTERNAL_REFERENCE_STORAGE.

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.

From-SVN: r95501
parent ca2cc05c
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> 2005-02-23 Kazu Hirata <kazu@cs.umass.edu>
* parse.y: Update copyright. * parse.y: Update copyright.
......
...@@ -273,6 +273,7 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO ...@@ -273,6 +273,7 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO
{ {
case STATIC_STORAGE: case STATIC_STORAGE:
case EXTERNAL_DEFINITION_STORAGE: case EXTERNAL_DEFINITION_STORAGE:
case EXTERNAL_REFERENCE_STORAGE:
break; break;
case AUTOMATIC_STORAGE: case AUTOMATIC_STORAGE:
...@@ -324,6 +325,17 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO ...@@ -324,6 +325,17 @@ storage typename NAME LEFT_PARENTHESIS parameters_opt RIGHT_PARENTHESIS SEMICOLO
STORAGE_CLASS (prod), STORAGE_CLASS (prod),
NUMERIC_TYPE (type), NUMERIC_TYPE (type),
first_parms, tok->tp.tok.location); 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 { ...@@ -332,7 +344,6 @@ NAME LEFT_BRACE {
struct prod_token_parm_item *proto; struct prod_token_parm_item *proto;
struct prod_token_parm_item search_prod; struct prod_token_parm_item search_prod;
struct prod_token_parm_item* tok; struct prod_token_parm_item* tok;
struct prod_token_parm_item *this_parm;
tok = $1; tok = $1;
SYMBOL_TABLE_NAME ((&search_prod)) = tok; SYMBOL_TABLE_NAME ((&search_prod)) = tok;
search_prod.category = token_category; search_prod.category = token_category;
...@@ -346,20 +357,9 @@ NAME LEFT_BRACE { ...@@ -346,20 +357,9 @@ NAME LEFT_BRACE {
gcc_assert (proto->tp.pro.code); gcc_assert (proto->tp.pro.code);
tree_code_create_function_initial (proto->tp.pro.code, tok->tp.tok.location, 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
} }
variable_defs_opt statements_opt RIGHT_BRACE { variable_defs_opt statements_opt RIGHT_BRACE {
struct prod_token_parm_item* tok; struct prod_token_parm_item* tok;
tok = $1; tok = $1;
...@@ -610,7 +610,7 @@ INTEGER { ...@@ -610,7 +610,7 @@ INTEGER {
; ;
function_invocation: 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 *prod;
struct prod_token_parm_item* tok; struct prod_token_parm_item* tok;
struct prod_token_parm_item search_prod; struct prod_token_parm_item search_prod;
...@@ -677,6 +677,13 @@ NAME LEFT_PARENTHESIS expressions_with_commas RIGHT_PARENTHESIS { ...@@ -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: expressions_with_commas:
expression { expression {
struct prod_token_parm_item *exp; struct prod_token_parm_item *exp;
......
...@@ -325,6 +325,7 @@ tree_code_create_function_prototype (unsigned char* chars, ...@@ -325,6 +325,7 @@ tree_code_create_function_prototype (unsigned char* chars,
tree type_node; tree type_node;
tree fn_type; tree fn_type;
tree fn_decl; tree fn_decl;
tree parm_list = NULL_TREE;
/* Build the type. */ /* Build the type. */
id = get_identifier ((const char*)chars); id = get_identifier ((const char*)chars);
...@@ -378,6 +379,37 @@ tree_code_create_function_prototype (unsigned char* chars, ...@@ -378,6 +379,37 @@ tree_code_create_function_prototype (unsigned char* chars,
gcc_unreachable (); 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. */ /* Process declaration of function defined elsewhere. */
rest_of_decl_compilation (fn_decl, 1, 0); rest_of_decl_compilation (fn_decl, 1, 0);
...@@ -386,21 +418,16 @@ tree_code_create_function_prototype (unsigned char* chars, ...@@ -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 /* Output code for start of function; the decl of the function is in
PREV_SAVED (as created by tree_code_create_function_prototype), PREV_SAVED (as created by tree_code_create_function_prototype),
the function is at line number LINENO in file FILENAME. The the function is at line number LINENO in file FILENAME. The
parameter details are in the lists PARMS. Returns nothing. */ parameter details are in the lists PARMS. Returns nothing. */
void void
tree_code_create_function_initial (tree prev_saved, tree_code_create_function_initial (tree prev_saved,
location_t loc, location_t loc)
struct prod_token_parm_item* parms)
{ {
tree fn_decl; tree fn_decl;
tree param_decl;
tree parm_decl;
tree parm_list;
tree resultdecl; tree resultdecl;
struct prod_token_parm_item* this_parm;
struct prod_token_parm_item* parm;
fn_decl = prev_saved; fn_decl = prev_saved;
gcc_assert (fn_decl); gcc_assert (fn_decl);
...@@ -426,40 +453,6 @@ tree_code_create_function_initial (tree prev_saved, ...@@ -426,40 +453,6 @@ tree_code_create_function_initial (tree prev_saved,
DECL_SOURCE_LOCATION (resultdecl) = loc; DECL_SOURCE_LOCATION (resultdecl) = loc;
DECL_RESULT (fn_decl) = resultdecl; 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. */ /* Create a new level at the start of the function. */
pushlevel (0); pushlevel (0);
...@@ -721,7 +714,7 @@ tree_code_get_expression (unsigned int exp_type, ...@@ -721,7 +714,7 @@ tree_code_get_expression (unsigned int exp_type,
break; break;
case EXP_FUNCTION_INVOCATION: case EXP_FUNCTION_INVOCATION:
gcc_assert (op1 && op2); gcc_assert (op1);
{ {
tree fun_ptr; tree fun_ptr;
fun_ptr = fold (build1 (ADDR_EXPR, fun_ptr = fold (build1 (ADDR_EXPR,
......
...@@ -36,14 +36,13 @@ void tree_ggc_storage_always_used (void *m); ...@@ -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_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); tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1);
void tree_code_create_function_initial (tree prev_saved, void tree_code_create_function_initial (tree prev_saved,
location_t loc, location_t loc);
struct prod_token_parm_item* parms);
void tree_code_create_function_wrapup (location_t loc); void tree_code_create_function_wrapup (location_t loc);
tree tree_code_create_function_prototype (unsigned char* chars, tree tree_code_create_function_prototype (unsigned char* chars,
unsigned int storage_class, unsigned int storage_class,
unsigned int ret_type, unsigned int ret_type,
struct prod_token_parm_item* parms, struct prod_token_parm_item* parms,
location_t loc); location_t loc);
tree tree_code_create_variable (unsigned int storage_class, tree tree_code_create_variable (unsigned int storage_class,
unsigned char* chars, unsigned char* chars,
unsigned int length, unsigned int length,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment