summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-10-25 01:28:12 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-10-25 01:28:12 +0000
commitb09388569655f44edd4a4282f3af316db2838a92 (patch)
tree984cf31b00e81c71e03f8a9127b71578dfc5493d
parentaf8cc282ab43f0239cd1157844664548f282427c (diff)
downloadbcm5719-llvm-b09388569655f44edd4a4282f3af316db2838a92.tar.gz
bcm5719-llvm-b09388569655f44edd4a4282f3af316db2838a92.zip
Consider used attributes in hidden decls.
Without this patch we would warn and fail to output the function in the test. llvm-svn: 193388
-rw-r--r--clang/lib/Sema/SemaDecl.cpp10
-rw-r--r--clang/test/SemaCXX/warn-unused-filescoped.cpp6
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ba789284060..2edebaba343 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2099,6 +2099,12 @@ static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
/// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
AvailabilityMergeKind AMK) {
+ if (UsedAttr *OldAttr = Old->getMostRecentDecl()->getAttr<UsedAttr>()) {
+ UsedAttr *NewAttr = OldAttr->clone(Context);
+ NewAttr->setInherited(true);
+ New->addAttr(NewAttr);
+ }
+
if (!Old->hasAttrs() && !New->hasAttrs())
return;
@@ -2136,6 +2142,10 @@ void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
}
}
+ // Already handled.
+ if (isa<UsedAttr>(*i))
+ continue;
+
if (mergeDeclAttribute(*this, New, *i, Override))
foundAny = true;
}
diff --git a/clang/test/SemaCXX/warn-unused-filescoped.cpp b/clang/test/SemaCXX/warn-unused-filescoped.cpp
index 65f10e6695a..b0af5b33227 100644
--- a/clang/test/SemaCXX/warn-unused-filescoped.cpp
+++ b/clang/test/SemaCXX/warn-unused-filescoped.cpp
@@ -187,4 +187,10 @@ namespace UndefinedInternalStaticMember {
}
}
+namespace test8 {
+static void func();
+void bar() { void func() __attribute__((used)); }
+static void func() {}
+}
+
#endif
OpenPOWER on IntegriCloud