fab icon indicating copy to clipboard operation
fab copied to clipboard

Detect and error on duplicate module definitions

Open MatthewHambley opened this issue 7 months ago • 1 comments

Module names must be unique in order for dependency analysis to work. (This is after preprocessing) Therefore if two source files contain modules with the same name (or worse a single file with duplicate modules) that is an error condition. It should be reported and build aborted.

MatthewHambley avatar Apr 30 '25 09:04 MatthewHambley

There is a comment in analysis:

    if duplicates:
        # we don't break the build because these symbols might not be
        # required to build the executable.
        # todo: put a big warning at the end of the build?

Not sure if this reason is good enough. FWIW, in a tool in psyclone we collect all warning and error messages, and the caller can query these messages to handle them later. Am happy to port this tool across if that should be useful.

hiker avatar Apr 30 '25 09:04 hiker

UMDP3 coding standards state that modules should not be used twice (presumably actually more than once?):

For code portability, be careful not to USE <module> twice in a routine for the same MODULE, especially where using ONLY. This can lead to compiler Warning and Error messages.

For this reason, I think it's reasonable to cause the build to fail - at least as a default action.

t00sa avatar Jul 29 '25 13:07 t00sa

After having a quick chat with @t00sa I'm happy to pick up this issue and start work on it.

Pierre-siddall avatar Aug 08 '25 14:08 Pierre-siddall