This is an archive of the discontinued LLVM Phabricator instance.

[flang][Preprocessor] Diagnose incorrect invocation of function-like macros
Needs ReviewPublic

Authored by rogfer01 on Aug 10 2023, 1:00 AM.

Details

Summary

During preprocessor expansion of a function-like macro, if the number of arguments is not acceptable for the macro or we fail to find the right parenthesis, we silently skip the expansion. This may be confusing to a user that is using a macro incorrectly (specially if the unexpanded stream of tokens is still valid Fortran). This change adds a diagnostic for these cases.

Diff Detail

Event Timeline

rogfer01 created this revision.Aug 10 2023, 1:00 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 10 2023, 1:00 AM
rogfer01 requested review of this revision.Aug 10 2023, 1:00 AM
rogfer01 added a comment.EditedAug 23 2023, 3:50 AM

Any thoughts on this @klausler ?

This check would preclude defining some cases of a function with a Fortran generic interface and using a function-like macro to define or override another case.

If the preprocessor doesn't catch this condition, semantics or the linker will get it later.