aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-22 15:57:07 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-22 15:57:07 +0000
commitaf130823cbac5c02f7fe57a5733ee511f5a3ac98 (patch)
treeacb2bdc77d2bd9efb28e9dfd85b649eb80235ad0
parentb681fb180dd1d1e8659006f1987711dcc92a6241 (diff)
Don't allow template argument deduction to deduce a placeholder type,
ever. Fixes PR10939. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140304 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp4
-rw-r--r--test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp17
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 762e51a32c..add8e10831 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -977,6 +977,10 @@ DeduceTemplateArguments(Sema &S,
// cv-list T
if (const TemplateTypeParmType *TemplateTypeParm
= Param->getAs<TemplateTypeParmType>()) {
+ // Just skip any attempts to deduce from a placeholder type.
+ if (Arg->isPlaceholderType())
+ return Sema::TDK_Success;
+
unsigned Index = TemplateTypeParm->getIndex();
bool RecanonicalizeArg = false;
diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
index 25ce99fc10..c150a6123c 100644
--- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -83,4 +83,21 @@ struct S {
}
};
+namespace PR10939 {
+ struct X {
+ int method(int);
+ int method(float);
+ };
+
+ template<typename T> T g(T);
+
+ void f(X *x) {
+ auto value = x->method; // expected-error{{variable 'value' with type 'auto' has incompatible initializer of type '<bound member function type>'}}
+ if (value) { }
+
+ auto funcptr = &g<int>;
+ int (*funcptr2)(int) = funcptr;
+ }
+}
+
// TODO: if the initializer is a braced-init-list, deduce auto as std::initializer_list<T>.