Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2012-08-27 21:24:34 -0400
committerSergey Prigogin2012-08-27 21:24:34 -0400
commit80fe6566a7fd6b9ccebdd3dd347c05eb85885e6a (patch)
tree4d6c22905fb7ee1487526b2200ca04cc59544172
parentfa4aeee25d417af95c1f2e32bc0f88ee9cec2780 (diff)
downloadorg.eclipse.cdt-80fe6566a7fd6b9ccebdd3dd347c05eb85885e6a.tar.gz
org.eclipse.cdt-80fe6566a7fd6b9ccebdd3dd347c05eb85885e6a.tar.xz
org.eclipse.cdt-80fe6566a7fd6b9ccebdd3dd347c05eb85885e6a.zip
Fixed ArrayStoreException, ClassCastException and NPE.
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java78
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java2
6 files changed, 87 insertions, 15 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
index a3bc301dad..da4a20f4cd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java
@@ -148,6 +148,9 @@ public class Value implements IValue {
buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG3));
buf.putLong(lv);
}
+ } else if (fFixedValue != null) {
+ buf.putByte((byte) (ITypeMarshalBuffer.VALUE | ITypeMarshalBuffer.FLAG4));
+ buf.putCharArray(fFixedValue);
} else {
buf.putByte((ITypeMarshalBuffer.VALUE));
fEvaluation.marshal(buf, true);
@@ -169,7 +172,10 @@ public class Value implements IValue {
long val= buf.getLong();
return Value.create(val);
}
-
+ if ((firstByte & ITypeMarshalBuffer.FLAG4) != 0) {
+ char[] fixedValue = buf.getCharArray();
+ return new Value(fixedValue, null);
+ }
ISerializableEvaluation eval= buf.unmarshalEvaluation();
if (eval instanceof ICPPEvaluation)
return new Value(null, (ICPPEvaluation) eval);
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 2b9af86d06..ff98ac89ce 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
@@ -179,12 +179,7 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat
T[] newArray= array.clone();
for (int i = 0; i < newArray.length; i++) {
IBinding specializedMember = specialClass.specializeMember(array[i], point);
- try {
- newArray[i]= (T) specializedMember;
- } catch (ArrayStoreException e) {
- throw new ArrayStoreException("Can't cast " + specializedMember.getClass() + //$NON-NLS-1$
- " to " + array.getClass().getComponentType().getName()); //$NON-NLS-1$
- }
+ newArray[i]= (T) specializedMember;
}
return newArray;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
index 25fb6187c7..cf551dd59e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionCallExpression.java
@@ -32,6 +32,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExpressionList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
@@ -43,7 +44,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFixed;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalFunctionCall;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.EvalTypeId;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.LookupData;
-import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
public class CPPASTFunctionCallExpression extends ASTNode
implements ICPPASTFunctionCallExpression, IASTAmbiguityParent {
@@ -301,7 +301,7 @@ public class CPPASTFunctionCallExpression extends ASTNode
ICPPEvaluation[] args= new ICPPEvaluation[fArguments.length + 1];
args[0]= functionName.getEvaluation();
for (int i = 1; i < args.length; i++) {
- args[i]= ((ICPPASTExpression) fArguments[i - 1]).getEvaluation();
+ args[i]= ((ICPPASTInitializerClause) fArguments[i - 1]).getEvaluation();
}
return new EvalFunctionCall(args);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
index 58a39f498f..7c5327c549 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java
@@ -20,24 +20,31 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IBinding;
+import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IField;
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.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
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;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
+import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
+import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.core.runtime.Assert;
@@ -47,11 +54,76 @@ import org.eclipse.core.runtime.Assert;
public class CPPClassSpecialization extends CPPSpecialization
implements ICPPClassSpecialization, ICPPInternalClassTypeMixinHost {
- public final static class RecursionResolvingBinding extends ProblemBinding {
- public RecursionResolvingBinding(IASTNode node, char[] arg) {
+ public static class RecursionResolvingBinding extends ProblemBinding implements ICPPMember {
+ public static RecursionResolvingBinding createFor(IBinding original, IASTNode point) {
+ if (original instanceof ICPPMethod)
+ return new RecursionResolvingMethod(point, original.getNameCharArray());
+ if (original instanceof ICPPField)
+ return new RecursionResolvingField(point, original.getNameCharArray());
+ return new RecursionResolvingBinding(point, original.getNameCharArray());
+ }
+
+ private RecursionResolvingBinding(IASTNode node, char[] arg) {
super(node, IProblemBinding.SEMANTIC_RECURSION_IN_LOOKUP, arg);
Assert.isTrue(CPPASTNameBase.sAllowRecursionBindings, getMessage());
}
+
+ @Override
+ public int getVisibility() {
+ return ICPPASTVisibilityLabel.v_public;
+ }
+
+ @Override
+ public ICPPClassType getClassOwner() {
+ return null;
+ }
+ }
+
+ public final static class RecursionResolvingField extends RecursionResolvingBinding implements ICPPField {
+ public RecursionResolvingField(IASTNode node, char[] arg) {
+ super(node, arg);
+ }
+
+ @Override
+ public ICompositeType getCompositeTypeOwner() {
+ return null;
+ }
+ }
+
+ public final static class RecursionResolvingMethod extends RecursionResolvingBinding implements ICPPMethod {
+ public RecursionResolvingMethod(IASTNode node, char[] arg) {
+ super(node, arg);
+ }
+
+ @Override
+ public ICPPParameter[] getParameters() {
+ return ICPPParameter.EMPTY_CPPPARAMETER_ARRAY;
+ }
+
+ @Override
+ public int getRequiredArgumentCount() {
+ return 0;
+ }
+
+ @Override
+ public IScope getFunctionScope() {
+ return null;
+ }
+
+ @Override
+ public boolean isNoReturn() {
+ return false;
+ }
+
+ @Override
+ public boolean isDestructor() {
+ return false;
+ }
+
+ @Override
+ public ICPPFunctionType getType() {
+ return new ProblemFunctionType(getID());
+ }
}
private ICPPClassSpecializationScope specScope;
@@ -87,7 +159,7 @@ public class CPPClassSpecialization extends CPPSpecialization
fInProgress.set(set);
}
if (!set.add(original))
- return new RecursionResolvingBinding(point, original.getNameCharArray());
+ return RecursionResolvingBinding.createFor(original, point);
}
IBinding result= CPPTemplates.createSpecialization(this, original, point);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java
index 4d82579e7b..1bbe094e1a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassSpecialization.java
@@ -114,8 +114,7 @@ public class CompositeCPPClassSpecialization extends CompositeCPPClassType imple
fInProgress.set(set);
}
if (!set.add(original))
- return new RecursionResolvingBinding(null, null);
-
+ return RecursionResolvingBinding.createFor(original, point);
}
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
set.remove(original);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java
index 172691c8e7..35b992c3f5 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassSpecialization.java
@@ -132,7 +132,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
fInProgress.set(set);
}
if (!set.add(original))
- return new RecursionResolvingBinding(null, null);
+ return RecursionResolvingBinding.createFor(original, point);
}
IBinding newSpec= CPPTemplates.createSpecialization(this, original, point);
set.remove(original);

Back to the top