diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -12102,6 +12102,11 @@ if (Loc.isMacroID()) return; + // Do not diagnose if both LHS and RHS are macros. + if (XorLHS.get()->getExprLoc().isMacroID() && + XorRHS.get()->getExprLoc().isMacroID()) + return; + bool Negative = false; bool ExplicitPlus = false; const auto *LHSInt = dyn_cast(XorLHS.get()); diff --git a/clang/test/SemaCXX/warn-xor-as-pow.cpp b/clang/test/SemaCXX/warn-xor-as-pow.cpp --- a/clang/test/SemaCXX/warn-xor-as-pow.cpp +++ b/clang/test/SemaCXX/warn-xor-as-pow.cpp @@ -65,6 +65,7 @@ res = 2 ^ 0x4; res = 2 ^ 04; + res = TWO ^ TEN; res = 0x2 ^ 10; res = 0X2 ^ 10; res = 02 ^ 10;