Skip to content

[AST Print] Attribute asm is dumped in the incorrect location #162126

@giulianobelinassi

Description

@giulianobelinassi

With the following input saved as test.c (input code from glibc):

extern const char _libc_intl_domainname[]; extern typeof (_libc_intl_domainname) _libc_intl_domainname asm("__GI__libc_intl_domainname") __attribute__((visibility("hidden"))); 

This input is successfully accepted by clang, as it shows no output:

$ clang -S test.c 

However, dumping the AST:

$ clang -Xclang -ast-print -S test.c -o test.print.c 

dumps an output that is not accepted by clang:

clang -S test.print.c test.print.c:2:98: error: expected ';' after top level declarator 2 | extern typeof (_libc_intl_domainname) _libc_intl_domainname __attribute__((visibility("hidden"))) asm("__GI__libc_intl_domainname"); | ^ | ; 1 error generated. 

Output of clang --version:

$ clang --version clang version 21.1.1 Target: x86_64-suse-linux Thread model: posix InstalledDir: /usr/bin 

Related PRs: 87281, #88600
Requesting comments from @vgvassilev

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions