diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-18 01:20:53 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-18 01:20:53 +0000 |
commit | e24e8df7f2b15e0e0378aa8b65d85f1d3b8a348e (patch) | |
tree | 76b8fd18403158028bfbeeb8db6ac71d470a33aa /gcc/c-parse.in | |
parent | 2c5cfd29351c033307ae950dbd7bf6b6c56872f2 (diff) | |
download | ppe42-gcc-e24e8df7f2b15e0e0378aa8b65d85f1d3b8a348e.tar.gz ppe42-gcc-e24e8df7f2b15e0e0378aa8b65d85f1d3b8a348e.zip |
* c-common.c (flag_objc_sjlj_exceptions): New.
* c-common.h (flag_objc_sjlj_exceptions): Declare.
* c-opts.c (c_common_handle_option): Set it.
(c_common_post_options): Handle interation of different
objective-c exception and runtime switches.
* c-decl.c (c_eh_initialized_p): New.
(finish_decl): Use it instead of local eh_initialized_p.
* c-parse.in (nested_function, notype_nested_function): Record
the result of compstmt.
(compstmt_or_error): Likewise.
(compstmt): Don't add_stmt the result.
(stmt): Don't return anything. Rewrite objc try and sync rules.
(objc_try_stmt, objc_catch_list): Remove.
(objc_catch_block, objc_finally_block): Remove.
(objc_catch_prefix, objc_catch_clause, objc_opt_catch_list): New.
(objc_try_catch_clause, objc_finally_clause): New.
(objc_try_catch_stmt): Rewrite.
* c-tree.h (c_eh_initialized_p): Declare.
* c-opt (fobjc-sjlj-exceptions): New.
* except.c (output_function_exception_table): Don't call cgraph
on non-decls.
* objc/objc-act.c (UTAG_EXCDATA_VAR, UTAG_CAUGHTEXC_VAR,
UTAG_RETHROWEXC_VAR, UTAG_EVALONCE_VAR, struct val_stack,
catch_count_stack, exc_binding_stack, if_nesting_count,
blk_nesting_count, objc_enter_block, objc_exit_block,
objc_declare_variable, val_stack_push, val_stack_pop,
objc_build_try_enter_fragment, objc_build_extract_expr,
objc_build_try_exit_fragment, objc_build_extract_fragment,
objc_build_try_prologue, objc_build_try_epilogue,
objc_build_catch_stmt, objc_build_catch_epilogue,
objc_build_finally_prologue, objc_build_finally_epilogue,
objc_build_try_catch_finally_stmt, objc_build_synchronized_prologue,
objc_build_synchronized_epilogue): Remove.
(objc_create_temporary_var, struct objc_try_context, cur_try_context,
objc_eh_runtime_type, objc_init_exceptions, objc_build_exc_ptr,
next_sjlj_build_try_exit, next_sjlj_build_enter_and_setjmp,
next_sjlj_build_exc_extract, next_sjlj_build_catch_list,
next_sjlj_build_try_catch_finally, objc_begin_try_stmt,
objc_begin_catch_clause, objc_finish_catch_clause,
objc_build_finally_clause, objc_finish_try_stmt,
objc_build_synchronized): New.
(objc_is_object_id, objc_is_class_id): New.
(objc_comptypes): Use them.
(build_next_objc_exception_stuff): Break NeXT sjlj out from
build_objc_exception_stuff.
(synth_module_prologue): Update to match.
(objc_build_throw_stmt): Use cur_try_context to decide if
we're in a @catch.
* objc/objc-act.h: Update prototypes.
(OCTI_EXCEPTION_BLK_STACK, objc_exception_block_stack): Remove.
testsuite/
* objc.dg/sync-1.m: New.
* objc.dg/try-catch-1.m: Don't force next runtime.
* objc.dg/try-catch-3.m, objc.dg/try-catch-4.m: Likewise.
* objc.dg/try-catch-2.m: Likewise. Enable everywhere. Remove
shadowed catch clause.
* objc.dg/try-catch-5.m: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83332 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-parse.in')
-rw-r--r-- | gcc/c-parse.in | 144 |
1 files changed, 61 insertions, 83 deletions
diff --git a/gcc/c-parse.in b/gcc/c-parse.in index 118573ced5f..d3e39af6858 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -251,7 +251,6 @@ do { \ %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING %type <ttype> superclass -%type <itype> objc_try_catch_stmt objc_finally_block @@end_ifobjc %{ @@ -1515,7 +1514,7 @@ designator: ; nested_function: - declarator + declarator { if (pedantic) pedwarn ("ISO C forbids nested functions"); @@ -1527,25 +1526,25 @@ nested_function: YYERROR1; } } - old_style_parm_decls save_location + old_style_parm_decls save_location { tree decl = current_function_decl; DECL_SOURCE_LOCATION (decl) = $4; store_parm_decls (); } -/* This used to use compstmt_or_error. - That caused a bug with input `f(g) int g {}', - where the use of YYERROR1 above caused an error - which then was handled by compstmt_or_error. - There followed a repeated execution of that same rule, - which called YYERROR1 again, and so on. */ - compstmt + /* This used to use compstmt_or_error. That caused a bug with + input `f(g) int g {}', where the use of YYERROR1 above caused + an error which then was handled by compstmt_or_error. There + followed a repeated execution of that same rule, which called + YYERROR1 again, and so on. */ + compstmt { tree decl = current_function_decl; + add_stmt ($6); finish_function (); pop_function_context (); add_decl_stmt (decl); } ; notype_nested_function: - notype_declarator + notype_declarator { if (pedantic) pedwarn ("ISO C forbids nested functions"); @@ -1557,18 +1556,18 @@ notype_nested_function: YYERROR1; } } - old_style_parm_decls save_location + old_style_parm_decls save_location { tree decl = current_function_decl; DECL_SOURCE_LOCATION (decl) = $4; store_parm_decls (); } -/* This used to use compstmt_or_error. - That caused a bug with input `f(g) int g {}', - where the use of YYERROR1 above caused an error - which then was handled by compstmt_or_error. - There followed a repeated execution of that same rule, - which called YYERROR1 again, and so on. */ - compstmt + /* This used to use compstmt_or_error. That caused a bug with + input `f(g) int g {}', where the use of YYERROR1 above caused + an error which then was handled by compstmt_or_error. There + followed a repeated execution of that same rule, which called + YYERROR1 again, and so on. */ + compstmt { tree decl = current_function_decl; + add_stmt ($6); finish_function (); pop_function_context (); add_decl_stmt (decl); } @@ -2029,7 +2028,7 @@ label_decl: It causes syntax errors to ignore to the next openbrace. */ compstmt_or_error: compstmt - {} + { add_stmt ($1); } | error compstmt ; @@ -2060,8 +2059,7 @@ compstmt_primary_start: ; compstmt: compstmt_start compstmt_nostart - { add_stmt (c_end_compound_stmt ($1, true)); - $$ = NULL_TREE; } + { $$ = c_end_compound_stmt ($1, true); } ; if_prefix: @@ -2226,37 +2224,27 @@ xexpr: /* Parse a single real statement, not including any labels. */ stmt: compstmt - { stmt_count++; $$ = $1; } + { stmt_count++; add_stmt ($1); } | expr ';' - { stmt_count++; - $$ = c_expand_expr_stmt ($1); } + { stmt_count++; c_expand_expr_stmt ($1); } | c99_block_start select_or_iter_stmt - { add_stmt (c_end_compound_stmt ($1, flag_isoc99)); - $$ = NULL_TREE; } + { add_stmt (c_end_compound_stmt ($1, flag_isoc99)); } | BREAK ';' { stmt_count++; if (!(c_in_iteration_stmt || c_in_case_stmt)) - { - error ("break statement not within loop or switch"); - $$ = NULL_TREE; - } + error ("break statement not within loop or switch"); else - $$ = add_stmt (build_break_stmt ()); } + add_stmt (build_break_stmt ()); } | CONTINUE ';' { stmt_count++; if (!c_in_iteration_stmt) - { - error ("continue statement not within a loop"); - $$ = NULL_TREE; - } + error ("continue statement not within a loop"); else - $$ = add_stmt (build_continue_stmt ()); } + add_stmt (build_continue_stmt ()); } | RETURN ';' - { stmt_count++; - $$ = c_expand_return (NULL_TREE); } + { stmt_count++; c_expand_return (NULL_TREE); } | RETURN expr ';' - { stmt_count++; - $$ = c_expand_return ($2); } + { stmt_count++; c_expand_return ($2); } | asm_stmt | GOTO identifier ';' { tree decl; @@ -2265,71 +2253,61 @@ stmt: if (decl != 0) { TREE_USED (decl) = 1; - $$ = add_stmt (build_stmt (GOTO_EXPR, decl)); + add_stmt (build_stmt (GOTO_EXPR, decl)); } - else - $$ = NULL_TREE; } | GOTO '*' expr ';' { if (pedantic) pedwarn ("ISO C forbids `goto *expr;'"); stmt_count++; $3 = convert (ptr_type_node, $3); - $$ = add_stmt (build_stmt (GOTO_EXPR, $3)); } + add_stmt (build_stmt (GOTO_EXPR, $3)); } | ';' - { $$ = NULL_TREE; } + { } @@ifobjc | AT_THROW expr ';' - { stmt_count++; - $$ = objc_build_throw_stmt ($2); - } + { stmt_count++; objc_build_throw_stmt ($2); } | AT_THROW ';' - { stmt_count++; - $$ = objc_build_throw_stmt (NULL_TREE); - } + { stmt_count++; objc_build_throw_stmt (NULL_TREE); } | objc_try_catch_stmt - { objc_build_finally_prologue (); } - objc_finally_block - { $$ = objc_build_try_catch_finally_stmt ($1, $3); } - | AT_SYNCHRONIZED '(' expr ')' - { objc_build_synchronized_prologue ($3); } - compstmt - { $$ = objc_build_synchronized_epilogue (); } + { } + | AT_SYNCHRONIZED '(' expr ')' save_location compstmt + { stmt_count++; objc_build_synchronized ($5, $3, $6); } ; -objc_try_catch_stmt: - objc_try_stmt - { objc_build_try_epilogue (1); } - objc_catch_list - { objc_build_catch_epilogue (); $$ = 1; } - | objc_try_stmt - { objc_build_try_epilogue (0); $$ = 0; } +objc_catch_prefix: + AT_CATCH '(' parm ')' + { objc_begin_catch_clause ($3); } ; +objc_catch_clause: + objc_catch_prefix '{' compstmt_nostart + { objc_finish_catch_clause (); } + | objc_catch_prefix '{' error '}' + { objc_finish_catch_clause (); } + ; -objc_try_stmt: - AT_TRY - { objc_build_try_prologue (); } - compstmt +objc_opt_catch_list: + /* empty */ + | objc_opt_catch_list objc_catch_clause ; -objc_catch_list: - objc_catch_list objc_catch_block - | objc_catch_block +objc_try_catch_clause: + AT_TRY save_location compstmt + { stmt_count++; objc_begin_try_stmt ($2, $3); } + objc_opt_catch_list ; -objc_catch_block: - AT_CATCH '(' parm ')' - { objc_build_catch_stmt ($3); } - compstmt - { stmt_count++; } +objc_finally_clause: + AT_FINALLY save_location compstmt + { objc_build_finally_clause ($2, $3); } ; -objc_finally_block: - AT_FINALLY compstmt - { $$ = 1; } - | /* NULL */ - { $$ = 0; } +objc_try_catch_stmt: + objc_try_catch_clause + { objc_finish_try_stmt (); } + | objc_try_catch_clause objc_finally_clause + { objc_finish_try_stmt (); } @@end_ifobjc ; |