Skip to content

Commit c66ec11

Browse files
committed
[clang][Sema] Don't warn for implicit uses of builtins in system headers
Signed-off-by: Sarnie, Nick <[email protected]>
1 parent a073bb5 commit c66ec11

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,9 +2376,14 @@ NamedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
23762376
return nullptr;
23772377
}
23782378

2379+
// Warn for implicit uses of header dependent libraries,
2380+
// except in system headers.
23792381
if (!ForRedeclaration &&
23802382
(Context.BuiltinInfo.isPredefinedLibFunction(ID) ||
2381-
Context.BuiltinInfo.isHeaderDependentFunction(ID))) {
2383+
Context.BuiltinInfo.isHeaderDependentFunction(ID)) &&
2384+
(!getDiagnostics().getSuppressSystemWarnings() ||
2385+
!Context.getSourceManager().isInSystemHeader(
2386+
Context.getSourceManager().getSpellingLoc(Loc)))) {
23822387
Diag(Loc, LangOpts.C99 ? diag::ext_implicit_lib_function_decl_c99
23832388
: diag::ext_implicit_lib_function_decl)
23842389
<< Context.BuiltinInfo.getName(ID) << R;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#define MACRO(x,y) _InterlockedOr64(x,y);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -fms-extensions -fsyntax-only -verify -triple arm64-windows -isystem %S/Inputs %s
2+
3+
// expected-no-diagnostics
4+
#include <builtin-system-header.h>
5+
6+
void foo() {
7+
MACRO(0,0);
8+
}

0 commit comments

Comments
 (0)