When a warning is raised from the expansion of a system macro that
involves pasted token, there was still situations were they were not
skipped, as showcased by this issue:
https://bugzilla.redhat.com/show_bug.cgi?id=
1472437
Differential Revision: https://reviews.llvm.org/D59413
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360885
91177308-0d34-0410-b5e6-
96231b3b80d8
// This happens when the macro is the result of a paste, in that case
// its spelling is the scratch memory, so we take the parent context.
- if (isWrittenInScratchSpace(getSpellingLoc(loc)))
- return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+ // There can be several level of token pasting.
+ if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+ do {
+ loc = getImmediateMacroCallerLoc(loc);
+ } while (isWrittenInScratchSpace(getSpellingLoc(loc)));
+ return isInSystemMacro(loc);
+ }
return isInSystemHeader(getSpellingLoc(loc));
}
#include <no-warn-in-system-macro.c.inc>
+#define MACRO(x) x
+
int main(void)
{
double foo = 1.0;
if (isnan(foo))
return 1;
- return 0;
+
+ MACRO(isnan(foo));
+
+ return 0;
}