Index: include/clang/Basic/SourceManager.h =================================================================== --- include/clang/Basic/SourceManager.h +++ include/clang/Basic/SourceManager.h @@ -1453,7 +1453,11 @@ /// Returns whether \p Loc is expanded from a macro in a system header. bool isInSystemMacro(SourceLocation loc) const { - return loc.isMacroID() && isInSystemHeader(getSpellingLoc(loc)); + return loc.isMacroID() && + (isInSystemHeader(getSpellingLoc(loc)) || + // 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. + isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)))); } /// The size of the SLocEntry that \p FID represents. Index: test/Misc/no-warn-in-system-macro.c =================================================================== --- /dev/null +++ test/Misc/no-warn-in-system-macro.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s 2>&1 | FileCheck -allow-empty %s +// CHECK-NOT: warning: + +#include + +int main(void) +{ + double foo = 1.0; + + if (isnan(foo)) + return 1; + return 0; +} Index: test/Misc/no-warn-in-system-macro.c.inc =================================================================== --- /dev/null +++ test/Misc/no-warn-in-system-macro.c.inc @@ -0,0 +1,9 @@ +extern int __isnanf(float f); +extern int __isnan(double f); +extern int __isnanl(long double f); +#define isnan(x) \ + (sizeof (x) == sizeof (float) \ + ? __isnanf (x) \ + : sizeof (x) == sizeof (double) \ + ? __isnan (x) : __isnanl (x)) +