Skip to content

Commit bf03089

Browse files
committed
Permit prefixed attributes with lists of declarations
1 parent 29dbae6 commit bf03089

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

regression/ansi-c/gcc_attributes9/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ const char* __attribute__((section("s"))) bar1();
88
const char* __attribute__((section("s"),weak)) bar2();
99
const char* __attribute__((section("s"))) __attribute__((weak)) bar();
1010

11+
volatile int __attribute__((__section__(".init.data1"))) txt_heap_base1;
12+
volatile int __attribute__((__section__(".init.data3"))) txt_heap_base, __attribute__((__section__(".init.data4"))) txt_heap_size;
13+
1114
#endif
1215

1316
int main()

src/ansi-c/c_storage_spec.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,7 @@ class c_storage_spect
8282
a.is_register |=b.is_register;
8383
a.is_inline |=b.is_inline;
8484
a.is_thread_local |=b.is_thread_local;
85-
a.is_weak |=b.is_weak;
86-
if(!b.alias.empty()) a.alias=b.alias;
87-
if(!b.asm_label.empty()) a.asm_label=b.asm_label;
88-
if(!b.section.empty()) a.section=b.section;
85+
// attributes belong to the declarator, don't replace them
8986

9087
return a;
9188
}

src/ansi-c/parser.y

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,18 +971,19 @@ declaring_list:
971971
// add the initializer
972972
to_ansi_c_declaration(stack($$)).add_initializer(stack($5));
973973
}
974-
| declaring_list ',' declarator
974+
| declaring_list ',' gcc_type_attribute_opt declarator
975975
post_declarator_attributes_opt
976976
{
977977
// type attribute goes into declarator
978-
$3=merge($4, $3);
979-
PARSER.add_declarator(stack($1), stack($3));
978+
$5=merge($5, $3);
979+
$4=merge($5, $4);
980+
PARSER.add_declarator(stack($1), stack($4));
980981
}
981982
initializer_opt
982983
{
983984
// add in the initializer
984985
$$=$1;
985-
to_ansi_c_declaration(stack($$)).add_initializer(stack($6));
986+
to_ansi_c_declaration(stack($$)).add_initializer(stack($7));
986987
}
987988
;
988989

0 commit comments

Comments
 (0)