Mark as referenced the functions from instantiated UserDefinedLiterals.
Fixes rdar://13589856
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179078 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index f68de26..8356095 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -6173,6 +6173,8 @@
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformUserDefinedLiteral(UserDefinedLiteral *E) {
+ if (FunctionDecl *FD = E->getDirectCallee())
+ SemaRef.MarkFunctionReferenced(E->getLocStart(), FD);
return SemaRef.MaybeBindToTemporary(E);
}
diff --git a/test/SemaCXX/cxx11-user-defined-literals-unused.cpp b/test/SemaCXX/cxx11-user-defined-literals-unused.cpp
new file mode 100644
index 0000000..cd93ffb
--- /dev/null
+++ b/test/SemaCXX/cxx11-user-defined-literals-unused.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s -Wunused
+
+namespace {
+double operator"" _x(long double value) { return double(value); }
+int operator"" _ii(long double value) { return int(value); } // expected-warning {{not needed and will not be emitted}}
+}
+
+namespace rdar13589856 {
+ template<class T> double value() { return 3.2_x; }
+ template<class T> int valuei() { return 3.2_ii; }
+
+ double get_value() { return value<double>(); }
+}