mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Fix potential NPE.
This commit is contained in:
parent
da0b0d3b57
commit
47a208f1d4
3 changed files with 17 additions and 10 deletions
|
@ -70,8 +70,9 @@ public abstract class ASTAmbiguousNode extends ASTNode {
|
|||
|
||||
int minIssues = Integer.MAX_VALUE;
|
||||
for (IASTNode alternative : alternatives) {
|
||||
// flush scope, if this is not the first alternative
|
||||
if (nodeToReplace != this && scope instanceof IASTInternalScope) {
|
||||
// flush scope, even if this is the first alternative. The ambiguous node may have contributed an
|
||||
// invalid binding to the scope during the resolution of other ambiguous nodes.
|
||||
if (scope instanceof IASTInternalScope) {
|
||||
try {
|
||||
((IASTInternalScope) scope).flushCache();
|
||||
} catch (DOMException e) {
|
||||
|
|
|
@ -31,9 +31,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
|||
*/
|
||||
public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
|
||||
|
||||
private IType[] fArguments;
|
||||
private ObjectMap fArgmap;
|
||||
private ICPPClassTemplate fClassTemplate;
|
||||
private final IType[] fArguments;
|
||||
private final ObjectMap fArgmap;
|
||||
private final ICPPClassTemplate fClassTemplate;
|
||||
|
||||
public CPPDeferredClassInstance(ICPPClassTemplate orig, ObjectMap argMap, IType[] arguments) {
|
||||
super(orig);
|
||||
|
|
|
@ -1086,15 +1086,21 @@ public class CPPTemplates {
|
|||
|
||||
IType[] result = new IType[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
if (params[i] instanceof IASTNode) {
|
||||
result[i] = CPPVisitor.createType((IASTNode) params[i]);
|
||||
} else if (params[i] instanceof IParameter) {
|
||||
IType type= null;
|
||||
final Object param = params[i];
|
||||
if (param instanceof IASTNode) {
|
||||
type= CPPVisitor.createType((IASTNode) param);
|
||||
} else if (param instanceof IParameter) {
|
||||
try {
|
||||
result[i] = ((IParameter) params[i]).getType();
|
||||
type= ((IParameter) param).getType();
|
||||
} catch (DOMException e) {
|
||||
result[i] = e.getProblem();
|
||||
type= e.getProblem();
|
||||
}
|
||||
}
|
||||
// prevent null pointer exception when the type cannot be determined
|
||||
// happens when templates with still ambiguous template-ids are accessed during
|
||||
// resolution of other ambiguities.
|
||||
result[i]= type == null ? new CPPBasicType(-1, 0) : type;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue