Tool/software: TI C/C++ Compiler
Given the source file main.c
#define FOO 1 #define FOO 4 int main(void) { return 0; }
If we compile with MISRA rule 20.1 enabled, or any combination of rules including 20.1:
Building file: "../main.c"
Invoking: ARM Compiler
"/home/user/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armcl" -mv4 --code_state=32 --include_path="/home/user/ccs_workspace_v8/asdasd" --include_path="/home/user/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/include" -g --diag_warning=225 --diag_wrap=off --display_error_number --check_misra="20.1" --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"
Finished building: "../main.c"
Withouth this check, we can see that we get warning #48-D, as we should.
Building file: "../main.c"
Invoking: ARM Compiler
"/home/user/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/bin/armcl" -mv4 --code_state=32 --include_path="/home/user/ccs_workspace_v8/asdasd" --include_path="/home/user/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.2.LTS/include" -g --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="main.d_raw" "../main.c"
"../main.c", line 7: warning #48-D: incompatible redefinition of macro "FOO" (declared at line 6)
Finished building: "../main.c"
Is this a bug?