summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-09-05 01:09:43 (EDT)
committerSergey Prigogin2013-09-05 20:15:50 (EDT)
commit62c4e62ff3f6a06da21c4df2cee2e9acc284449f (patch)
tree7d7447a94a16826d07d27381701343ebf73f79d5
parent499bc0f1a7709a0d544a43b168ca2dd56fade8e9 (diff)
downloadorg.eclipse.cdt-62c4e62ff3f6a06da21c4df2cee2e9acc284449f.zip
org.eclipse.cdt-62c4e62ff3f6a06da21c4df2cee2e9acc284449f.tar.gz
org.eclipse.cdt-62c4e62ff3f6a06da21c4df2cee2e9acc284449f.tar.bz2
Bug 416284 - Unsafe method call, using nested templatesrefs/changes/47/16147/2
Change-Id: I08732af62f43c03f362d4602736ef6b8e0f227e9 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/16147 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--codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java8
2 files changed, 18 insertions, 6 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java
index c9bd97f..aa705df 100644
--- a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java
+++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/AbstractClassInstantiationCheckerTest.java
@@ -331,4 +331,20 @@ public class AbstractClassInstantiationCheckerTest extends CheckerTestCase {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
+
+ // struct N {
+ // int node;
+ // };
+ //
+ // template <typename T>
+ // struct List {
+ // template <int T::*>
+ // struct Base {};
+ // };
+ //
+ // List<N>::Base<&N::node> base;
+ public void testUnsafeMethodCallException_bug416284() throws Exception {
+ // Just check that codan runs without any exceptions being thrown.
+ loadCodeAndRun(getAboveComment());
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
index 93d3cee..068e56c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java
@@ -25,7 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
@@ -203,11 +202,8 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
@Override
public ICPPMethod[] getImplicitMethods(IASTNode point) {
- ICPPClassScope origClassScope= (ICPPClassScope) specialClass.getSpecializedBinding().getCompositeScope();
- if (origClassScope == null) {
- return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
- }
- ICPPMethod[] methods= origClassScope.getImplicitMethods();
+ ICPPClassType origClass = specialClass.getSpecializedBinding();
+ ICPPMethod[] methods= ClassTypeHelper.getImplicitMethods(origClass, point);
return specializeMembers(methods, point);
}