+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.
{
case STATIC_STORAGE:
case EXTERNAL_DEFINITION_STORAGE:
+ case EXTERNAL_REFERENCE_STORAGE:
break;
case AUTOMATIC_STORAGE:
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
}
;
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;
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;
;
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;
}
;
+expressions_with_commas_opt:
+/* Nil. */ {
+$$ = 0
+}
+|expressions_with_commas { $$ = $1 }
+;
+
expressions_with_commas:
expression {
struct prod_token_parm_item *exp;
tree type_node;
tree fn_type;
tree fn_decl;
+ tree parm_list = NULL_TREE;
/* Build the type. */
id = get_identifier ((const 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);
/* 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);
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);
break;
case EXP_FUNCTION_INVOCATION:
- gcc_assert (op1 && op2);
+ gcc_assert (op1);
{
tree fun_ptr;
fun_ptr = fold (build1 (ADDR_EXPR,
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,