annotate sources/nest-and-goto.c @ 2:50e23a4b2f40

add many files.
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Fri, 05 Feb 2010 10:00:05 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 static void
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 cbc_finish_labeled_goto (location_t loc,
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 tree label, tree retval)
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 {
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 tree tlab;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 tree cond;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 tree cstmt = c_begin_compound_stmt (true);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 tlab = define_label (loc, label);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 gcc_assert (tlab);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 decl_attributes (&tlab, NULL_TREE, 0);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 add_stmt (build_stmt (LABEL_EXPR, tlab));
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 tree ret = c_finish_return (retval);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 TREE_USED(ret) = 1;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 cond = integer_zero_node;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 tree if_body = c_end_compound_stmt (cstmt, true);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 TREE_SIDE_EFFECTS (cstmt) = 1;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 c_finish_if_stmt (loc, cond, if_body, NULL_TREE, false);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 }
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 static tree
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 cbc_finish_nested_function (location_t loc,
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 tree label, tree retval_decl)
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 {
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 tree fnbody;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 tree _retval_decl, _envp_decl;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 struct c_declarator *declarator;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 tree ident;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 struct c_arg_info *args;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 struct c_declspecs *specs;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 struct c_typespec t;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 {
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 push_scope ();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 declare_parm_level ();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 /*tree retval_type = TREE_TYPE(retval_decl);*/
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 _retval_decl = build_decl (PARM_DECL,
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 get_identifier ("_retval"),
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 TREE_TYPE (retval_decl));
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 DECL_SOURCE_LOCATION (_retval_decl) = loc;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 DECL_ARTIFICIAL (_retval_decl) = 1;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 DECL_ARG_TYPE (_retval_decl) = TREE_TYPE(retval_decl);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 pushdecl (_retval_decl);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 finish_decl (_retval_decl, NULL_TREE, NULL_TREE);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 _envp_decl = build_decl (PARM_DECL,
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 get_identifier ("_envp"),
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 ptr_type_node );
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 DECL_SOURCE_LOCATION (_envp_decl) = loc;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 DECL_ARTIFICIAL (_envp_decl) = 1;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 DECL_ARG_TYPE (_envp_decl) = ptr_type_node;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 pushdecl (_envp_decl);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 finish_decl (_envp_decl, NULL_TREE, NULL_TREE);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 args = get_parm_info(false);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 pop_scope();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 }
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 t.kind = ctsk_resword;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 t.spec = get_identifier("void");
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 specs = build_null_declspecs();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 declspecs_add_type (specs, t);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 finish_declspecs (specs);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 /* make nested function. */
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 declarator =
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 build_id_declarator (
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 get_identifier ("_cbc_internal_return"));
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 declarator = build_function_declarator (args, declarator);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 c_push_function_context ();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 if (!start_function (specs, declarator, NULL_TREE))
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 {
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 c_pop_function_context();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 gcc_assert (0);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 }
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 store_parm_decls ();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 /* start compound statement. */
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 tree cstmt = c_begin_compound_stmt (true);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 add_stmt (build_modify_expr
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 (loc, retval_decl,
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 NOP_EXPR, _retval_decl));
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 tree stmt = c_finish_goto_label (label);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94 /* end compound statement. */
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 fnbody = c_end_compound_stmt (cstmt, true);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 TREE_SIDE_EFFECTS (cstmt) = 1;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 /* finish declaration of nested function. */
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 tree decl = current_function_decl;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 add_stmt (fnbody);
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 finish_function ();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 c_pop_function_context ();
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
104 add_stmt (build_stmt (DECL_EXPR, decl));
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 return decl;
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
106
50e23a4b2f40 add many files.
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 }