summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-08-18 03:12:10 (EDT)
committer Sergey Prigogin2013-09-05 20:02:18 (EDT)
commit68a9017f2e477e3e9cd10e3ebde73e3cde12f77f (patch)
treebb5a590540df23f02d2d786698a866b7066e8109
parente9d295e1a6d348bd198159633a53e500510857ee (diff)
downloadorg.eclipse.cdt-68a9017f2e477e3e9cd10e3ebde73e3cde12f77f.zip
org.eclipse.cdt-68a9017f2e477e3e9cd10e3ebde73e3cde12f77f.tar.gz
org.eclipse.cdt-68a9017f2e477e3e9cd10e3ebde73e3cde12f77f.tar.bz2
Bug 415198 - [false positive] Semantic error for decltype(func())::namerefs/changes/69/15569/9
in dependent context Change-Id: I12d41dd88fb5fd5e501907bc709efdabc44f3d17 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/15569 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.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java29
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java19
3 files changed, 50 insertions, 19 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 f0055d6..a8cedf6 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
@@ -8039,4 +8039,25 @@ public class AST2TemplateTests extends AST2TestBase {
public void testOutOfLineMethodOfPartialSpecialization_401152() throws Exception {
parseAndCheckBindings();
}
+
+ // template <typename T>
+ // T foo(T);
+ //
+ // template <typename T>
+ // struct U {
+ // typedef typename decltype(foo(T()))::type type;
+ // };
+ //
+ // struct S {
+ // typedef int type;
+ // };
+ //
+ // int main() {
+ // U<S>::type x;
+ // }
+ public void testDependentDecltypeInNameQualifier_415198() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper();
+ helper.assertNonProblem("decltype(foo(T()))::type");
+ assertSameType((ITypedef) helper.assertNonProblem("U<S>::type"), CommonTypes.int_);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
index 1a176a0..e5cf9c4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java
@@ -1266,11 +1266,18 @@ public class CPPTemplates {
}
if (type instanceof ICPPUnknownBinding) {
- IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, within, point);
- if (binding instanceof IType)
- return (IType) binding;
-
- return type;
+ if (type instanceof TypeOfDependentExpression) {
+ ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation();
+ ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
+ if (instantiated != eval)
+ return instantiated.getTypeOrFunctionSet(point);
+ } else {
+ IBinding binding= resolveUnknown((ICPPUnknownBinding) type, tpMap, packOffset, within, point);
+ if (binding instanceof IType)
+ return (IType) binding;
+
+ return type;
+ }
}
if (within != null && type instanceof IBinding) {
@@ -1348,13 +1355,6 @@ public class CPPTemplates {
return typeContainer;
}
- if (type instanceof TypeOfDependentExpression) {
- ICPPEvaluation eval = ((TypeOfDependentExpression) type).getEvaluation();
- ICPPEvaluation instantiated = eval.instantiate(tpMap, packOffset, within, Value.MAX_RECURSION_DEPTH, point);
- if (instantiated != eval)
- return instantiated.getTypeOrFunctionSet(point);
- }
-
return type;
} catch (DOMException e) {
return e.getProblem();
@@ -2646,6 +2646,11 @@ public class CPPTemplates {
if (type instanceof IBinding)
return (IBinding) type;
}
+ if (unknown instanceof TypeOfDependentExpression) {
+ IType type= instantiateType((IType) unknown, tpMap, packOffset, within, point);
+ if (type instanceof IBinding)
+ return (IBinding) type;
+ }
return unknown;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
index c1bccc5..fda7831 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeOfDependentExpression.java
@@ -12,11 +12,13 @@
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
+import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPEvaluation;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownType;
import org.eclipse.core.runtime.CoreException;
@@ -24,10 +26,11 @@ import org.eclipse.core.runtime.CoreException;
/**
* Represents the type of a dependent expression.
*/
-public class TypeOfDependentExpression implements ICPPUnknownType, ISerializableType {
+public class TypeOfDependentExpression extends CPPUnknownBinding implements ICPPUnknownType, ISerializableType {
private final ICPPEvaluation fEvaluation;
public TypeOfDependentExpression(ICPPEvaluation evaluation) {
+ super(evaluation.getSignature());
fEvaluation= evaluation;
}
@@ -42,12 +45,8 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable
}
@Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
+ public TypeOfDependentExpression clone() {
+ return (TypeOfDependentExpression) super.clone();
}
public char[] getSignature() {
@@ -73,4 +72,10 @@ public class TypeOfDependentExpression implements ICPPUnknownType, ISerializable
return new TypeOfDependentExpression((ICPPEvaluation) eval);
return ProblemType.UNKNOWN_FOR_EXPRESSION;
}
+
+ @Override
+ public IBinding getOwner() {
+ // We won't know until instantiation.
+ return null;
+ }
}