Menu

Parser bug?

2020-06-04
2020-06-05
  • Pedro Navarro

    Pedro Navarro - 2020-06-04

    Hi,

    I have this code:

    #define ENABLE(FEATURE) (defined ENABLE_##FEATURE && ENABLE_##FEATURE)
    #define ENABLE_FOO 1
    
    #if ENABLE(FOO)
    #error FOO is enabled // <-- expected result
    #else
    #error FOO is not enabled // <-- cppcheck gets here
    #endif
    

    cppcheck stops processing with "FOO is not enabled".

    If I expand the macro myself everything is fine:

    #define ENABLE(FEATURE) (defined ENABLE_##FEATURE && ENABLE_##FEATURE)
    #define ENABLE_FOO 1
    
    #if (defined ENABLE_FOO && ENABLE_FOO)
    #error FOO is enabled // <-- expected result
    #else
    #error FOO is not enabled 
    #endif
    

    cppcheck correctly shows "FOO is enabled"

    Pedro

     

    Last edit: Pedro Navarro 2020-06-04
  • Daniel Marjamäki

    Thanks for reporting.

    I created this issue: https://github.com/danmar/simplecpp/issues/192

    A PR would be much appreciated.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.