1

I'm trying to create a static rule to check the token passing for defensive programming in a SIL4 application.

The rule is the following: "Each functions shall have a const uint_32 as last parameter"

ie:

uint_32 foo(uint_32 a, uint_32 b, const uint_32 c)   ok 
uint_32 foo(uint_32 a, uint_32 b, const uint_16 c)  NOK
uint_32 foo(uint_32 a, uint_32 b, uint_32 c)  NOK
uint_32 foo(uint_32 a, const uint_32 b, uint_32 c)  NOK 

There's someone that may help me? I'm groping in the dark

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • If you do not find a way to do it with Parasoft you could always use a custom Frama-C plugin. In this case use `Global.iter_on_fundecs` to inspect each function. A `fundec` is a record with a field `sformals` which is a list of argument variables; you want to check the type of the last element of this list. – Pascal Cuoq May 20 '11 at 11:50

1 Answers1

1

You can first collect numbers of all parameters (using ParamNumber property) in a collector. Then select parameter with ParamNumber equal to the highest collected number (you can use MAX() to get that). Then you can check if this parameter has appropriate type.

Irek