[cfe-commits] r93178 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp
Douglas Gregor
dgregor at apple.com
Mon Jan 11 11:55:36 PST 2010
Author: dgregor
Date: Mon Jan 11 13:55:36 2010
New Revision: 93178
URL: http://llvm.org/viewvc/llvm-project?rev=93178&view=rev
Log:
When resolving a single function template specialization to a
function, be sure to adjust the resulting argument type to a pointer
(if necessary). Fixes PR5910 and PR5949.
Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=93178&r1=93177&r2=93178&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Mon Jan 11 13:55:36 2010
@@ -1473,8 +1473,11 @@
return TDK_FailedOverloadResolution;
}
- // Get the type of the resolved argument.
+ // Get the type of the resolved argument, and adjust it per
+ // C++0x [temp.deduct.call]p3.
ArgType = ResolvedArg->getType();
+ if (!ParamWasReference && ArgType->isFunctionType())
+ ArgType = Context.getPointerType(ArgType);
if (ArgType->isPointerType() || ArgType->isMemberPointerType())
TDF |= TDF_IgnoreQualifiers;
Modified: cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp?rev=93178&r1=93177&r2=93178&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp Mon Jan 11 13:55:36 2010
@@ -9,3 +9,36 @@
// Z is deduced to be double
f("aa",3.0); // expected-error{{no matching}}
}
+
+// PR5910
+namespace PR5910 {
+ template <typename T>
+ void Func() {}
+
+ template <typename R>
+ void Foo(R (*fp)());
+
+ void Test() {
+ Foo(Func<int>);
+ }
+}
+
+// PR5949
+namespace PR5949 {
+ struct Bar;
+
+ template <class Container>
+ void quuz(const Container &cont) {
+ }
+
+ template<typename T>
+ int Foo(Bar *b, void (*Baz)(const T &t), T * = 0) {
+ return 0;
+ }
+
+ template<typename T>
+ int Quux(Bar *b, T * = 0)
+ {
+ return Foo<T>(b, quuz);
+ }
+}
More information about the cfe-commits
mailing list