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
5419 continue;5419 continue;
5420 }5420 }
5421 while (1) { /* iterate thru each declaration */5421 while (1) { /* iterate thru each declaration */
5422 char *asm_label; // associated asm label
5422 type = btype;5423 type = btype;
5423 type_decl(&type, &ad, &v, TYPE_DIRECT);5424 type_decl(&type, &ad, &v, TYPE_DIRECT);
5424#if 05425#if 0
@@ -5439,6 +5440,18 @@ ST_FUNC void decl(int l) · 14 unmodified lines
5439 func_decl_list(sym);5440 func_decl_list(sym);
5440 }5441 }
5441 5442
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
5442 if (ad.weak)5455 if (ad.weak)
5443 type.t |= VT_WEAK;5456 type.t |= VT_WEAK;
5444#ifdef TCC_TARGET_PE5457#ifdef TCC_TARGET_PE
@@ -5548,39 +5561,15 @@ ST_FUNC void decl(int l) · 103 unmodified lines
5548 sym = sym_push(v, &type, INT_ATTR(&ad), 0);5561 sym = sym_push(v, &type, INT_ATTR(&ad), 0);
5549 sym->type.t |= VT_TYPEDEF;5562 sym->type.t |= VT_TYPEDEF;
5550 } else if ((type.t & VT_BTYPE) == VT_FUNC) {5563 } else if ((type.t & VT_BTYPE) == VT_FUNC) {
5551 char *asm_label; // associated asm label
5552 Sym *fn;
5553
5554 asm_label = NULL;
5555 /* external function definition */5564 /* external function definition */
5556 /* specific case for func_call attribute */5565 /* specific case for func_call attribute */
5557 type.ref->r = INT_ATTR(&ad);5566 type.ref->r = INT_ATTR(&ad);
5558 5567 external_sym(v, &type, 0, asm_label);
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);
5569 } else {5568 } else {
5570 char *asm_label; // associated asm label
5571
5572 /* not lvalue if array */5569 /* not lvalue if array */
5573 r = 0;5570 r = 0;
5574 asm_label = NULL;
5575 if (!(type.t & VT_ARRAY))5571 if (!(type.t & VT_ARRAY))
5576 r |= lvalue_type(type.t);5572 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 }
5584 has_init = (tok == '=');5573 has_init = (tok == '=');
5585 if ((btype.t & VT_EXTERN) ||5574 if ((btype.t & VT_EXTERN) ||
5586 ((type.t & VT_ARRAY) && (type.t & VT_STATIC) &&5575 ((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
2358extern int __attribute__((weak)) (*weak_fpb)();2358extern int __attribute__((weak)) (*weak_fpb)();
2359extern __attribute__((weak)) int (*weak_fpc)();2359extern __attribute__((weak)) int (*weak_fpc)();
2360 2360
2361extern int weak_asm_f1(void) asm("weak_asm_f1x") __attribute((weak));
2362extern int __attribute((weak)) weak_asm_f2(void) asm("weak_asm_f2x") ;
2363extern int __attribute((weak)) weak_asm_f3(void) asm("weak_asm_f3x") __attribute((weak));
2364extern int weak_asm_v1 asm("weak_asm_v1x") __attribute((weak));
2365extern int __attribute((weak)) weak_asm_v2 asm("weak_asm_v2x") ;
2366extern int __attribute((weak)) weak_asm_v3(void) asm("weak_asm_v3x") __attribute((weak));
2367
2361void __attribute__((weak)) weak_test(void)2368void __attribute__((weak)) weak_test(void)
2362{2369{
2363 printf("weak_f1=%d\n", weak_f1 ? weak_f1() : 123);2370 printf("weak_f1=%d\n", weak_f1 ? weak_f1() : 123);
@@ -2370,6 +2377,13 @@ void __attribute__((weak)) weak_test(void) · 6 unmodified lines
2370 printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);2377 printf("weak_fpa=%d\n",&weak_fpa ? weak_fpa() : 123);
2371 printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);2378 printf("weak_fpb=%d\n",&weak_fpb ? weak_fpb() : 123);
2372 printf("weak_fpc=%d\n",&weak_fpc ? weak_fpc() : 123);2379 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);
2373}2387}
2374 2388
2375int __attribute__((weak)) weak_f2() { return 222; }2389int __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