diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 47a84927268f..adbcafe4339d 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1905,6 +1905,12 @@ void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) { isa(MD)) return; + if (MD->getLocation().isMacroID()) { + SourceLocation MacroLoc = getSourceManager().getSpellingLoc(MD->getLocation()); + if (getSourceManager().isInSystemHeader(MacroLoc)) + return; + } + if (MD->size_overridden_methods() > 0) { Diag(MD->getLocation(), diag::warn_function_marked_not_override_overriding) << MD->getDeclName(); diff --git a/clang/test/SemaCXX/Inputs/override-system-header.h b/clang/test/SemaCXX/Inputs/override-system-header.h new file mode 100644 index 000000000000..9a1bde5a26b3 --- /dev/null +++ b/clang/test/SemaCXX/Inputs/override-system-header.h @@ -0,0 +1,3 @@ +// override-system-header.h to test out 'override' warning. +// rdar://18295240 +#define END_COM_MAP virtual unsigned AddRef(void) = 0; diff --git a/clang/test/SemaCXX/override-in-system-header.cpp b/clang/test/SemaCXX/override-in-system-header.cpp new file mode 100644 index 000000000000..88c53e4430a4 --- /dev/null +++ b/clang/test/SemaCXX/override-in-system-header.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -std=c++11 -isystem %S/Inputs %s -verify +// expected-no-diagnostics +// rdar://18295240 + +#include + +struct A +{ + virtual void x(); + END_COM_MAP; +}; + +struct B : A +{ + virtual void x() override; + END_COM_MAP; +};