Skip to contentSkip to conversation

Adding function attributes with SmPL?

cocci Markus Elfring 2 participants 3 messages Jan 16, 2023 – Jan 17, 2023

lore
Share & tools
lore
#0 lore raw

Hello,

I would occasionally like to adjust function attributes.
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html

Thus I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.1.1”).

@addition@
@@
 int must_be_checked(...)
+__attribute__ ((warn_unused_result))
 ;

Unfortunately, I stumbled on the following display.

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci add_warn_unused_result1.cocci …
plus: parse error:
  File "add_warn_unused_result1.cocci", line 4, column 1, charpos = 41
  around = '__attribute__',
  whole content = +__attribute__ ((warn_unused_result))

Can the software tool be extended accordingly?

Regards,
Markus

#1 lore raw
Quoted 27 lines · Markus Elfring

Hello,

I would occasionally like to adjust function attributes.
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html

Thus I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.1.1”).

@addition@
@@
 int must_be_checked(...)
+__attribute__ ((warn_unused_result))
 ;

Unfortunately, I stumbled on the following display.

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch --parse-cocci add_warn_unused_result1.cocci …
plus: parse error:
  File "add_warn_unused_result1.cocci", line 4, column 1, charpos = 41
  around = '__attribute__',
  whole content = +__attribute__ ((warn_unused_result))

Quoted 1 line

Can the software tool be extended accordingly?

Work on attributes is in progress.

julia