Skip to content
Snippets Groups Projects
Commit ccc11a19 authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

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

Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
Acked-by: default avatarNicolas Schier <n.schier@avm.de>
parent aa710cee
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment