History

genksyms: record attributes consistently for init-declarator

I believe the missing action here is a bug. For rules with no explicit action, the following default is used: { $$ = $1; } However, in this case, $1 is the value of attribute_opt itself. As a result, the value of attribute_opt is always NULL. The following test code demonstrates inconsistent behavior. int x __attribute__((__aligned__(4))); int y __attribute__((__aligned__(4))) = 0; The attribute is recorded only when followed by an initializer. This commit adds the correct action to propagate the value of the ATTRIBUTE_PHRASE token. With this change, the attribute in the example above is consistently recorded for both 'x' and 'y'. [Before] $ cat <<EOF | scripts/genksyms/genksyms -d int x __attribute__((__aligned__(4))); int y __attribute__((__aligned__(4))) = 0; EOF Defn for type0 x == <int x > Defn for type0 y == <int y __attribute__ ( ( __aligned__ ( 4 ) ) ) > Hash table occupancy 2/4096 = 0.000488281 [After] $ cat <<EOF | scripts/genksyms/genksyms -d int x __attribute__((__aligned__(4))); int y __attribute__((__aligned__(4))) = 0; EOF Defn for type0 x == <int x __attribute__ ( ( __aligned__ ( 4 ) ) ) > Defn for type0 y == <int y __attribute__ ( ( __aligned__ ( 4 ) ) ) > Hash table occupancy 2/4096 = 0.000488281

Masahiro Yamada committed 1 year ago

Commit ccc11a11 parent aa710ce1 file · +1 −1Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/genksyms/parse.y+1−1
@@ -480,7 +480,7 @@ member_bitfield_declarator: · 479 unmodified lines
480 480
481attribute_opt:481attribute_opt:
482 /* empty */ { $$ = NULL; }482 /* empty */ { $$ = NULL; }
483 | attribute_opt ATTRIBUTE_PHRASE483 | attribute_opt ATTRIBUTE_PHRASE { $$ = $2; }
484 ;484 ;
485 485
486enum_body:486enum_body:

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