diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-27 19:05:51 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-09-27 19:05:51 +0000 |
commit | 60acea49c1343e5494edb6da20cac6f9d0b6cfb0 (patch) | |
tree | 6a8b88bda5ae354cefeb603229bedd89b1168332 /lib/Sema/SemaDeclAttr.cpp | |
parent | db148be93c9af45da1f3aa9302c577618a56e6ea (diff) |
Issue warning for trivial cases of nonnull attributes
(on functions with no pointer arguments) but only when
the attribute has not been coming from a macro
instantiation in a header file. Fixes first part
of radar 6857843.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index dce1bf84fc..09feb50bd3 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -375,8 +375,13 @@ static void HandleNonNullAttr(Decl *d, const AttributeList &Attr, Sema &S) { // No pointer arguments? The attribute in this case is // trivially satisfied. - if (NonNullArgs.empty()) + if (NonNullArgs.empty()) { + // Warn the trivial case only if attribute is not coming from a + // macro instantiation. + if (Attr.getLoc().isFileID()) + S.Diag(Attr.getLoc(), diag::warn_attribute_nonnull_no_pointers); return; + } } unsigned* start = &NonNullArgs[0]; |