summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-03-07 03:55:24 (EST)
committer Sergey Prigogin2013-03-08 12:58:53 (EST)
commit395e7c941e7328d0fccc2d64f418879856de3a14 (patch)
tree19f1efe0edf02a6e5320c58d056a30adfd6fa7ca
parentd2f798e5b89c96769f8194a0e06057d0f08de1e9 (diff)
downloadorg.eclipse.cdt-395e7c941e7328d0fccc2d64f418879856de3a14.zip
org.eclipse.cdt-395e7c941e7328d0fccc2d64f418879856de3a14.tar.gz
org.eclipse.cdt-395e7c941e7328d0fccc2d64f418879856de3a14.tar.bz2
Bug 402498 - Name resolution error for unqualified function call withrefs/changes/22/10922/3
dependent argument Change-Id: I7de7ea4898c91f2c994b8b19e61c4f283620620e Reviewed-on: https://git.eclipse.org/r/10922 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java10
3 files changed, 28 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
index a95ce65..9206fb6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java
@@ -7488,4 +7488,12 @@ public class AST2TemplateTests extends AST2TestBase {
public void testRegression_401743b() throws Exception {
parseAndCheckBindings();
}
+
+ // template <typename T>
+ // void foo(T t) {
+ // bar(t);
+ // }
+ public void testUnqualifiedFunctionCallInTemplate_402498() throws Exception {
+ parseAndCheckBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java
index 88f0d3b..a990244 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredFunction.java
@@ -28,6 +28,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFunction, ICPPComputableFunction {
private static final ICPPFunctionType FUNCTION_TYPE=
new CPPFunctionType(ProblemType.UNKNOWN_FOR_EXPRESSION, IType.EMPTY_TYPE_ARRAY);
+ private static final ICPPFunction[] NO_CANDIDATES= {};
/**
* Creates a CPPDeferredFunction given a set of overloaded functions
@@ -43,6 +44,16 @@ public class CPPDeferredFunction extends CPPUnknownBinding implements ICPPFuncti
final IBinding owner = candidates[0].getOwner();
return new CPPDeferredFunction(owner, candidates[0].getNameCharArray(), candidates);
}
+
+ /**
+ * Creates a CPPDeferredFunction given a name. This is for cases where there
+ * are no candidates that could be passed to createForCandidates().
+ * @param name the name of the function
+ * @return the constructed CPPDeferredFunction
+ */
+ public static ICPPFunction createForName(char[] name) {
+ return new CPPDeferredFunction(null, name, NO_CANDIDATES);
+ }
private final IBinding fOwner;
private final ICPPFunction[] fCandidates;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
index 1186983..d9154a6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java
@@ -518,6 +518,15 @@ public class CPPSemantics {
}
}
+ // If this is the unqualified name of a function in a function call in a template and some
+ // of the function arguments are dependent, the name could be resolved via argument-dependent
+ // lookup at the point of instantiation.
+ if (binding == null) {
+ if (!data.qualified && data.isFunctionCall() && CPPTemplates.containsDependentType(data.getFunctionArgumentTypes())) {
+ binding = CPPDeferredFunction.createForName(lookupName.getSimpleID());
+ }
+ }
+
// If we're still null...
if (binding == null) {
if (name instanceof ICPPASTQualifiedName && declaration != null) {
@@ -555,7 +564,6 @@ public class CPPSemantics {
private static void doKoenigLookup(LookupData data) throws DOMException {
data.ignoreUsingDirectives = true;
- data.qualified = true;
Set<ICPPFunction> friendFns = new HashSet<ICPPFunction>(2);
Set<ICPPNamespaceScope> associated = getAssociatedScopes(data, friendFns);
for (ICPPNamespaceScope scope : associated) {