History

handle post-asm-label attributes on variables

Joe Soroka committed 15 years ago

Commit 3beb3831 parent 823f8322 files · +28 −25Browse files

Unified · Split

2 files
  1. tccgen.c +14 −25
  2. tests/tcctest.c +14 −0
tccgen.c+14−25
@@ -5419,6 +5419,7 @@ ST_FUNC void decl(int l) · 5418 unmodified lines
54195419 continue;
54205420 }
54215421 while (1) { /* iterate thru each declaration */
5422+ char *asm_label; // associated asm label
54225423 type = btype;
54235424 type_decl(&type, &ad, &v, TYPE_DIRECT);
54245425 #if 0
@@ -5439,6 +5440,18 @@ ST_FUNC void decl(int l) · 14 unmodified lines
54395440 func_decl_list(sym);
54405441 }
54415442
5443+ asm_label = NULL;
5444+ if (gnu_ext && (tok == TOK_ASM1 || tok == TOK_ASM2 || tok == TOK_ASM3)) {
5445+ CString astr;
5446+
5447+ asm_label_instr(&astr);
5448+ asm_label = tcc_strdup(astr.data);
5449+ cstr_free(&astr);
5450+
5451+ /* parse one last attribute list, after asm label */
5452+ parse_attribute(&ad);
5453+ }
5454+
54425455 if (ad.weak)
54435456 type.t |= VT_WEAK;
54445457 #ifdef TCC_TARGET_PE
@@ -5548,39 +5561,15 @@ ST_FUNC void decl(int l) · 103 unmodified lines
55485561 sym = sym_push(v, &type, INT_ATTR(&ad), 0);
55495562 sym->type.t |= VT_TYPEDEF;
55505563 } else if ((type.t & VT_BTYPE) == VT_FUNC) {
5551− char *asm_label; // associated asm label
5552− Sym *fn;
5553−
5554− asm_label = NULL;
55555564 /* external function definition */
55565565 /* specific case for func_call attribute */
55575566 type.ref->r = INT_ATTR(&ad);
5558−
5559− if (gnu_ext && (tok == TOK_ASM1 || tok == TOK_ASM2 || tok == TOK_ASM3)) {
5560− CString astr;
5561−
5562− asm_label_instr(&astr);
5563− asm_label = tcc_strdup(astr.data);
5564− cstr_free(&astr);
5565− }
5566− fn = external_sym(v, &type, 0, asm_label);
5567− if (gnu_ext && (tok == TOK_ATTRIBUTE1 || tok == TOK_ATTRIBUTE2))
5568− parse_attribute((AttributeDef *) &fn->type.ref->r);
5567+ external_sym(v, &type, 0, asm_label);
55695568 } else {
5570− char *asm_label; // associated asm label
5571−
55725569 /* not lvalue if array */
55735570 r = 0;
5574− asm_label = NULL;
55755571 if (!(type.t & VT_ARRAY))
55765572 r |= lvalue_type(type.t);
5577− if (tok == TOK_ASM1 || tok == TOK_ASM2 || tok == TOK_ASM3) {
5578− CString astr;
5579−
5580− asm_label_instr(&astr);
5581− asm_label = tcc_strdup(astr.data);
5582− cstr_free(&astr);
5583− }
55845573 has_init = (tok == '=');
55855574 if ((btype.t & VT_EXTERN) ||
55865575 ((type.t & VT_ARRAY) && (type.t & VT_STATIC) &&
tests/tcctest.c+14−0
@@ -2358,6 +2358,13 @@ extern int (*weak_fpa)() __attribute__((weak)); · 2357 unmodified lines
23582358 extern int __attribute__((weak)) (*weak_fpb)();
23592359 extern __attribute__((weak)) int (*weak_fpc)();
23602360
2361+extern int weak_asm_f1(void) asm("weak_asm_f1x") __attribute((weak));
2362+extern int __attribute((weak)) weak_asm_f2(void) asm("weak_asm_f2x") ;
2363+extern int __attribute((weak)) weak_asm_f3(void) asm("weak_asm_f3x") __attribute((weak));
2364+extern int weak_asm_v1 asm("weak_asm_v1x") __attribute((weak));
2365+extern int __attribute((weak)) weak_asm_v2 asm("weak_asm_v2x") ;
2366+extern int __attribute((weak)) weak_asm_v3(void) asm("weak_asm_v3x") __attribute((weak));
2367+
23612368 void __attribute__((weak)) weak_test(void)
23622369 {
23632370 printf("weak_f1=%d\n", weak_f1 ? weak_f1() : 123);
@@ -2370,6 +2377,13 @@ void __attribute__((weak)) weak_test(void) · 6 unmodified lines
23702377 printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);
23712378 printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);
23722379 printf("weak_fpc=%d\n",&weak_fpc ? weak_fpc() : 123);
2380+
2381+ printf("weak_asm_f1=%d\n", weak_asm_f1 != NULL);
2382+ printf("weak_asm_f2=%d\n", weak_asm_f2 != NULL);
2383+ printf("weak_asm_f3=%d\n", weak_asm_f3 != NULL);
2384+ printf("weak_asm_v1=%d\n",&weak_asm_v1 != NULL);
2385+ printf("weak_asm_v2=%d\n",&weak_asm_v2 != NULL);
2386+ printf("weak_asm_v3=%d\n",&weak_asm_v3 != NULL);
23732387 }
23742388
23752389 int __attribute__((weak)) weak_f2() { return 222; }

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