Hello Hercules Team,
A user is trying to check MISRA-C compliance of Halcogen 4.06.00 generated code using CCS v7. There are many warnings. This is easy to duplicate. I created a new RM42 project using Halcogen and just saved the generated files. I then created a new empty CCS v7 project that uses ARM compiler 16.9.3.LTS. I enabled "ALL" MISRA checks for the CCS project. Just building a single source file (adc.c), I get dozens of warnings. I then changed to only "REQUIRED" MISRA checks. I get far fewer warnings, but do still have warnings. Some of the warnings pertain to include files coming from the compiler. But others come from the Halcogen generated source file (adc.c) itself. For example:
ptr++;
"../source/adc.c", line 446: warning #1476-D: (MISRA-C:2004 17.4/R) Array indexing shall be the only allowed form of pointer arithmetic
CCS is supposed to be checking for compliance with MISRA-C:2004, which is the same version that Halcogen is supposed to be compliant with. I saw several other older posts on this subject to which responses suggested that Halcogen compliance was evaluated using a tool from LDRA. But, I'd think the example I give above is pretty straightforward and would be a violation using any tool, wouldn't it be?
How can users have confidence in Halcogen MISRA compliance if it cannot pass our own CCS check?
Any other suggestions/comments here?
--------
Update: I see the ptr++ code lines seem to have a waiver cited in the code comments:
"../source/adc.c", line 446: warning #1476-D: (MISRA-C:2004 17.4/R) Array indexing shall be the only allowed form of pointer arithmetic
Fair enough on that. There are still other warnings though that I cannot make sense out of. For example:
return adc->EVTIN;
"../source/adc.c", line 856: warning #1423-D: (MISRA-C:2004 17.6/R) The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist ("adc")
I'm not seeing where the address of an automatic var is being assigned to a persistant object. The code line is returning a value to the calling function.
--------
Thanks and regards,
David