This is an archive of the discontinued LLVM Phabricator instance.

Add new warning for compound punctuation tokens that are split across macro expansions or split by whitespace.
ClosedPublic

Authored by rsmith on Aug 27 2020, 4:46 PM.

Details

Summary

For example:

#define FOO(x) (x)
FOO({});

... forms a statement-expression after macro expansion. This warning
applies to '({' and '})' delimiting statement-expressions, '[[' and ']]'
delimiting attributes, and '::*' introducing a pointer-to-member.

The warning for forming these compound tokens across macro expansions
(or across files!) is enabled by default; the warning for whitespace
within the tokens is not, but is included in -Wall.

Diff Detail

Event Timeline

rsmith created this revision.Aug 27 2020, 4:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 27 2020, 4:46 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rsmith requested review of this revision.Aug 27 2020, 4:46 PM
rsmith edited the summary of this revision. (Show Details)Aug 27 2020, 4:51 PM
sbenza accepted this revision.Aug 28 2020, 6:41 AM
sbenza added inline comments.
clang/test/Parser/compound-token-split.cpp
31

Does this count as a "different" source file?
Or is it just an implementation detail of how clang uses FileIDs ?

This revision is now accepted and ready to land.Aug 28 2020, 6:41 AM
rsmith marked an inline comment as done.Aug 28 2020, 1:34 PM
rsmith added inline comments.
clang/test/Parser/compound-token-split.cpp
31

:) Yes, this is a consequence of how Clang uses FileIDs.

I guess it's debatable whether the includer and included file are "different", but I'm hoping no-one will be confused by the diagnostic. (I think it's one of those "if you ever see this diagnostic in practice you win a small prize" cases...)

This revision was landed with ongoing or failed builds.Aug 28 2020, 1:36 PM
This revision was automatically updated to reflect the committed changes.
rsmith marked an inline comment as done.