Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-11-14 23:24:15 -0500
committerSergey Prigogin2016-11-14 23:24:15 -0500
commit08eb54b46dee9899e91653c3d3ea37177e53efa9 (patch)
tree3a29325c0c179788653496a7f7f6a24f120f39c3
parent88b2f8564afb4e598b78f265c022c617a3100689 (diff)
downloadorg.eclipse.cdt-08eb54b46dee9899e91653c3d3ea37177e53efa9.tar.gz
org.eclipse.cdt-08eb54b46dee9899e91653c3d3ea37177e53efa9.tar.xz
org.eclipse.cdt-08eb54b46dee9899e91653c3d3ea37177e53efa9.zip
Bug 507511 - Template function resolution problem when using index
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java39
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java5
2 files changed, 43 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
index db5016d71d..4653d56350 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java
@@ -1182,6 +1182,45 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
assertEquals("int", ASTTypeUtil.getType(type));
}
+ // template <typename T>
+ // struct D;
+ //
+ // template <typename C, typename U>
+ // struct D<void (C::*)(U)> {
+ // typedef U type;
+ // };
+ //
+ // template <typename T>
+ // using E = typename D<decltype(&T::operator())>::type;
+ //
+ // template <typename T>
+ // struct G {
+ // typedef E<T> type;
+ // };
+ //
+ // template <typename T>
+ // using F = typename G<T>::type;
+ //
+ // template <typename T, typename U>
+ // struct B {};
+ //
+ // template <typename T>
+ // B<F<T>, int>* f(T t);
+ //
+ // template <typename U>
+ // void waldo(B<double, U>* e);
+
+ // struct A {
+ // void operator()(double x);
+ // };
+ //
+ // void test() {
+ // waldo(f(A()));
+ // }
+ public void testTemplateArgumentDeduction_507511() throws Exception {
+ checkBindings();
+ }
+
// class A {}; class B {}; class X {};
// template<typename T>
// class C {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
index 5cbe5b334c..5995218080 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
@@ -836,7 +836,10 @@ public class TemplateArgumentDeduction {
return tval.equals(sval);
}
- return fromType(p.getTypeValue(), a.getOriginalTypeValue(), false, point);
+ // Try to deduce from the original argument type, but if it fails, fall back to the simplified
+ // argument type.
+ return fromType(p.getTypeValue(), a.getOriginalTypeValue(), false, point)
+ || fromType(p.getTypeValue(), a.getTypeValue(), false, point);
}
private boolean fromType(IType p, IType a, boolean allowCVQConversion, IASTNode point) throws DOMException {

Back to the top