History

tccgen: nocode_wanted++/--

uses 'nocode_wanted' as a level couter instead of 'saved_nocode_wanted' everywhere.

grischka committed 9 years ago

Commit f7fc4f01 parent e5efd181 file · +37 −51Browse files

Unified · Split

tccgen.c+37−51
@@ -146,6 +146,7 @@ ST_FUNC void tccgen_start(TCCState *s1) · 145 unmodified lines
146146 funcname = "";
147147 anon_sym = SYM_FIRST_ANOM;
148148 section_sym = 0;
149+ const_wanted = 0;
149150 nocode_wanted = 1;
150151
151152 /* define some often used types */
@@ -4457,16 +4458,14 @@ ST_FUNC void unary(void) · 4305 unmodified lines
44574458 case TOK_builtin_expect:
44584459 {
44594460 /* __builtin_expect is a no-op for now */
4460− int saved_nocode_wanted;
44614461 next();
44624462 skip('(');
44634463 expr_eq();
44644464 skip(',');
4465− saved_nocode_wanted = nocode_wanted;
4466− nocode_wanted = 1;
4465+ nocode_wanted++;
44674466 expr_lor_const();
44684467 vpop();
4469− nocode_wanted = saved_nocode_wanted;
4468+ nocode_wanted--;
44704469 skip(')');
44714470 }
44724471 break;
@@ -4486,45 +4485,41 @@ ST_FUNC void unary(void) · 13 unmodified lines
44864485 break;
44874486 case TOK_builtin_choose_expr:
44884487 {
4489− int saved_nocode_wanted;
44904488 int64_t c;
44914489 next();
44924490 skip('(');
44934491 c = expr_const64();
44944492 skip(',');
44954493 if (!c) {
4496− saved_nocode_wanted = nocode_wanted;
4497− nocode_wanted = 1;
4494+ nocode_wanted++;
44984495 }
44994496 expr_eq();
45004497 if (!c) {
45014498 vpop();
4502− nocode_wanted = saved_nocode_wanted;
4499+ nocode_wanted--;
45034500 }
45044501 skip(',');
45054502 if (c) {
4506− saved_nocode_wanted = nocode_wanted;
4507− nocode_wanted = 1;
4503+ nocode_wanted++;
45084504 }
45094505 expr_eq();
45104506 if (c) {
45114507 vpop();
4512− nocode_wanted = saved_nocode_wanted;
4508+ nocode_wanted--;
45134509 }
45144510 skip(')');
45154511 }
45164512 break;
45174513 case TOK_builtin_constant_p:
45184514 {
4519− int saved_nocode_wanted, res;
4515+ int res;
45204516 next();
45214517 skip('(');
4522− saved_nocode_wanted = nocode_wanted;
4523− nocode_wanted = 1;
4518+ nocode_wanted++;
45244519 gexpr();
45254520 res = (vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST;
45264521 vpop();
4527− nocode_wanted = saved_nocode_wanted;
4522+ nocode_wanted--;
45284523 skip(')');
45294524 vpushi(res);
45304525 }
@@ -5054,14 +5049,13 @@ static void expr_land(void) · 523 unmodified lines
50545049 if (vtop->c.i) {
50555050 vpop();
50565051 } else {
5057− int saved_nocode_wanted = nocode_wanted;
5058− nocode_wanted = 1;
5052+ nocode_wanted++;
50595053 while (tok == TOK_LAND) {
50605054 next();
50615055 expr_or();
50625056 vpop();
50635057 }
5064− nocode_wanted = saved_nocode_wanted;
5058+ nocode_wanted--;
50655059 if (t)
50665060 gsym(t);
50675061 gen_cast(&int_type);
@@ -5098,14 +5092,13 @@ static void expr_lor(void) · 30 unmodified lines
50985092 if (!vtop->c.i) {
50995093 vpop();
51005094 } else {
5101− int saved_nocode_wanted = nocode_wanted;
5102− nocode_wanted = 1;
5095+ nocode_wanted++;
51035096 while (tok == TOK_LOR) {
51045097 next();
51055098 expr_land();
51065099 vpop();
51075100 }
5108− nocode_wanted = saved_nocode_wanted;
5101+ nocode_wanted--;
51095102 if (t)
51105103 gsym(t);
51115104 gen_cast(&int_type);
@@ -5153,7 +5146,6 @@ static void expr_cond(void) · 41 unmodified lines
51535146 int tt, u, r1, r2, rc, t1, t2, bt1, bt2, islv, c, g;
51545147 SValue sv;
51555148 CType type, type1, type2;
5156− int saved_nocode_wanted = nocode_wanted;
51575149
51585150 expr_lor();
51595151 if (tok == '?') {
@@ -5186,7 +5178,7 @@ static void expr_cond(void) · 26 unmodified lines
51865178
51875179 if (1) {
51885180 if (c == 0)
5189− nocode_wanted = 1;
5181+ nocode_wanted++;
51905182 if (!g)
51915183 gexpr();
51925184
@@ -5199,11 +5191,14 @@ static void expr_cond(void) · 6 unmodified lines
51995191 if (c < 0)
52005192 u = gjmp(0);
52015193 gsym(tt);
5202− nocode_wanted = saved_nocode_wanted;
5194+
5195+ if (c == 0)
5196+ nocode_wanted--;
52035197 if (c == 1)
5204− nocode_wanted = 1;
5198+ nocode_wanted++;
52055199 expr_cond();
5206− nocode_wanted = saved_nocode_wanted;
5200+ if (c == 1)
5201+ nocode_wanted--;
52075202
52085203 type2 = vtop->type;
52095204 t1 = type1.t;
@@ -5355,38 +5350,31 @@ ST_FUNC void gexpr(void) · 145 unmodified lines
53555350 /* parse an expression and return its type without any side effect. */
53565351 static void expr_type(CType *type)
53575352 {
5358− int saved_nocode_wanted;
53595353
5360− saved_nocode_wanted = nocode_wanted;
5361− nocode_wanted = 1;
5354+ nocode_wanted++;
53625355 gexpr();
53635356 *type = vtop->type;
53645357 vpop();
5365− nocode_wanted = saved_nocode_wanted;
5358+ nocode_wanted--;
53665359 }
53675360
53685361 /* parse a unary expression and return its type without any side
53695362 effect. */
53705363 static void unary_type(CType *type)
53715364 {
5372− int a;
5373−
5374− a = nocode_wanted;
5375− nocode_wanted = 1;
5365+ nocode_wanted++;
53765366 unary();
53775367 *type = vtop->type;
53785368 vpop();
5379− nocode_wanted = a;
5369+ nocode_wanted--;
53805370 }
53815371
53825372 /* parse a constant expression and return value in vtop. */
53835373 static void expr_const1(void)
53845374 {
5385− int a;
5386− a = const_wanted;
5387− const_wanted = 1;
5375+ const_wanted++;
53885376 expr_cond();
5389− const_wanted = a;
5377+ const_wanted--;
53905378 }
53915379
53925380 /* parse an integer constant and return its value. */
@@ -5552,7 +5540,7 @@ static void block(int *bsym, int *csym, int is_expr) · 159 unmodified lines
55525540 else
55535541 a = gvtst(1, 0);
55545542 if (cond == 0)
5555− nocode_wanted |= 2;
5543+ nocode_wanted |= 0x20000000;
55565544 block(bsym, csym, 0);
55575545 if (cond != 1)
55585546 nocode_wanted = saved_nocode_wanted;
@@ -5562,7 +5550,7 @@ static void block(int *bsym, int *csym, int is_expr) · 3 unmodified lines
55625550 d = gjmp(0);
55635551 gsym(a);
55645552 if (cond == 1)
5565− nocode_wanted |= 2;
5553+ nocode_wanted |= 0x20000000;
55665554 block(bsym, csym, 0);
55675555 gsym(d); /* patch else jmp */
55685556 if (cond != 0)
@@ -5571,7 +5559,7 @@ static void block(int *bsym, int *csym, int is_expr) · 2 unmodified lines
55715559 gsym(a);
55725560 } else if (tok == TOK_WHILE) {
55735561 int saved_nocode_wanted;
5574− nocode_wanted &= ~2;
5562+ nocode_wanted &= ~0x20000000;
55755563 next();
55765564 d = ind;
55775565 vla_sp_restore();
@@ -5718,7 +5706,7 @@ static void block(int *bsym, int *csym, int is_expr) · 140 unmodified lines
57185706 /* jump unless last stmt in top-level block */
57195707 if (tok != '}' || local_scope != 1)
57205708 rsym = gjmp(rsym);
5721− nocode_wanted |= 2;
5709+ nocode_wanted |= 0x20000000;
57225710 } else if (tok == TOK_BREAK) {
57235711 /* compute jump */
57245712 if (!bsym)
@@ -5726,7 +5714,7 @@ static void block(int *bsym, int *csym, int is_expr) · 1 unmodified line
57265714 *bsym = gjmp(*bsym);
57275715 next();
57285716 skip(';');
5729− nocode_wanted |= 2;
5717+ nocode_wanted |= 0x20000000;
57305718 } else if (tok == TOK_CONTINUE) {
57315719 /* compute jump */
57325720 if (!csym)
@@ -5738,7 +5726,7 @@ static void block(int *bsym, int *csym, int is_expr) · 5 unmodified lines
57385726 } else if (tok == TOK_FOR) {
57395727 int e;
57405728 int saved_nocode_wanted;
5741− nocode_wanted &= ~2;
5729+ nocode_wanted &= ~0x20000000;
57425730 next();
57435731 skip('(');
57445732 s = local_stack;
@@ -5784,7 +5772,7 @@ static void block(int *bsym, int *csym, int is_expr) · 39 unmodified lines
57845772 } else
57855773 if (tok == TOK_DO) {
57865774 int saved_nocode_wanted;
5787− nocode_wanted &= ~2;
5775+ nocode_wanted &= ~0x20000000;
57885776 next();
57895777 a = 0;
57905778 b = 0;
@@ -5844,7 +5832,7 @@ static void block(int *bsym, int *csym, int is_expr) · 53 unmodified lines
58445832 struct case_t *cr = tcc_malloc(sizeof(struct case_t));
58455833 if (!cur_switch)
58465834 expect("switch");
5847− nocode_wanted &= ~2;
5835+ nocode_wanted &= ~0x20000000;
58485836 next();
58495837 cr->v1 = cr->v2 = expr_const64();
58505838 if (gnu_ext && tok == TOK_DOTS) {
@@ -5917,7 +5905,7 @@ static void block(int *bsym, int *csym, int is_expr) · 66 unmodified lines
59175905 vla_sp_restore();
59185906 /* we accept this, but it is a mistake */
59195907 block_after_label:
5920− nocode_wanted &= ~2;
5908+ nocode_wanted &= ~0x20000000;
59215909 if (tok == '}') {
59225910 tcc_warning("deprecated use of label at end of compound statement");
59235911 } else {
@@ -6833,8 +6821,6 @@ static void func_decl_list(Sym *func_sym) · 909 unmodified lines
68336821 'cur_text_section' */
68346822 static void gen_function(Sym *sym)
68356823 {
6836− int saved_nocode_wanted = nocode_wanted;
6837−
68386824 nocode_wanted = 0;
68396825 ind = cur_text_section->data_offset;
68406826 /* NOTE: we patch the symbol size later */
@@ -6881,7 +6867,7 @@ static void gen_function(Sym *sym) · 40 unmodified lines
68816867 func_vt.t = VT_VOID; /* for safety */
68826868 func_var = 0; /* for safety */
68836869 ind = 0; /* for safety */
6884− nocode_wanted = saved_nocode_wanted;
6870+ nocode_wanted = 1;
68856871 check_vstack();
68866872 }
68876873

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t