appleseedlab / maki

A tool for analyzing syntactic and semantic properties of C Preprocessor macros in C programs
8 stars 3 forks source link

`IsInvokedWhereICERequired` ignores global vars and ICEs in typedefs #42

Closed PappasBrent closed 2 months ago

PappasBrent commented 2 months ago

Maki sets the IsInvokedWhereICERequired property for macro invocations appearing in the initializer for global variables, or in array sizes inside of typedefs, as false, when it should set them to true.

For example, in the following code snippet:

#define SIZE 10
int size = SIZE;
typedef char small_string[SIZE];

Maki sets the IsInvokedWhereICERequired property for both invocations of SIZE to false, when it should be set to true since both these invocations appear where integral constant expressions are required.

Any fix to this problem must additionally account for the fact that static local variables also need to be initialized with constant expressions, e.g., in the following snippet:

int foo(void) {
    static int bar = 0;
}

bar would need to be initialized with a integral constant expression.