1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 23:15:24 +02:00

Bug 513105 - Avoid pushing a null lookup point in CPPVisitor.createType()

ArrayDeque doesn't allow null elements.

Change-Id: Ib610cfedf02232d30b4fc4e1b4d4d5ba45d7aee3
This commit is contained in:
Nathan Ridge 2017-09-27 18:45:42 -04:00
parent bb9d1db323
commit 80dc8d9c25

View file

@ -2071,65 +2071,65 @@ public class CPPVisitor extends ASTQueries {
public static IType createType(IASTDeclarator declarator) { public static IType createType(IASTDeclarator declarator) {
// Resolve placeholders by default. // Resolve placeholders by default.
try { return createType(declarator, RESOLVE_PLACEHOLDERS);
CPPSemantics.pushLookupPoint(declarator);
return createType(declarator, RESOLVE_PLACEHOLDERS);
} finally {
CPPSemantics.popLookupPoint();
}
} }
public static IType createType(IASTDeclarator declarator, int flags) { public static IType createType(IASTDeclarator declarator, int flags) {
if (declarator == null) if (declarator == null)
return ProblemType.NO_NAME; return ProblemType.NO_NAME;
declarator= findOutermostDeclarator(declarator); CPPSemantics.pushLookupPoint(declarator);
IASTNode parent = declarator.getParent(); try {
declarator= findOutermostDeclarator(declarator);
IASTNode parent = declarator.getParent();
IASTDeclSpecifier declSpec = null; IASTDeclSpecifier declSpec = null;
boolean isPackExpansion= false; boolean isPackExpansion= false;
if (parent instanceof IASTSimpleDeclaration) { if (parent instanceof IASTSimpleDeclaration) {
declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
} else if (parent instanceof IASTParameterDeclaration) { } else if (parent instanceof IASTParameterDeclaration) {
declSpec = ((IASTParameterDeclaration) parent).getDeclSpecifier(); declSpec = ((IASTParameterDeclaration) parent).getDeclSpecifier();
} else if (parent instanceof IASTFunctionDefinition) { } else if (parent instanceof IASTFunctionDefinition) {
declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier(); declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier();
} else if (parent instanceof ICPPASTTypeId) { } else if (parent instanceof ICPPASTTypeId) {
final ICPPASTTypeId typeId = (ICPPASTTypeId) parent; final ICPPASTTypeId typeId = (ICPPASTTypeId) parent;
declSpec = typeId.getDeclSpecifier(); declSpec = typeId.getDeclSpecifier();
isPackExpansion= typeId.isPackExpansion(); isPackExpansion= typeId.isPackExpansion();
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
PlaceholderKind placeholder = usesAuto(declSpec); PlaceholderKind placeholder = usesAuto(declSpec);
if (placeholder != null) { if (placeholder != null) {
return createAutoType(declSpec, declarator, flags, placeholder); return createAutoType(declSpec, declarator, flags, placeholder);
} }
IType type = createType(declSpec); IType type = createType(declSpec);
type = makeConstIfConstexpr(type, declSpec, declarator); type = makeConstIfConstexpr(type, declSpec, declarator);
type = createType(type, declarator); type = createType(type, declarator);
// C++ specification 8.3.4.3 and 8.5.1.4 // C++ specification 8.3.4.3 and 8.5.1.4
IASTNode initClause= declarator.getInitializer(); IASTNode initClause= declarator.getInitializer();
if (initClause instanceof IASTEqualsInitializer) { if (initClause instanceof IASTEqualsInitializer) {
initClause= ((IASTEqualsInitializer) initClause).getInitializerClause(); initClause= ((IASTEqualsInitializer) initClause).getInitializerClause();
} }
if (initClause instanceof IASTInitializerList) { if (initClause instanceof IASTInitializerList) {
IType t= SemanticUtil.getNestedType(type, TDEF); IType t= SemanticUtil.getNestedType(type, TDEF);
if (t instanceof IArrayType) { if (t instanceof IArrayType) {
IArrayType at= (IArrayType) t; IArrayType at= (IArrayType) t;
if (at.getSize() == null) { if (at.getSize() == null) {
type= new CPPArrayType(at.getType(), IntegralValue.create(((IASTInitializerList) initClause).getSize())); type= new CPPArrayType(at.getType(), IntegralValue.create(((IASTInitializerList) initClause).getSize()));
}
} }
} }
}
if (isPackExpansion) { if (isPackExpansion) {
type= new CPPParameterPackType(type); type= new CPPParameterPackType(type);
}
return type;
} finally {
CPPSemantics.popLookupPoint();
} }
return type;
} }
private static IType createAutoParameterType(IASTDeclSpecifier declSpec, IASTDeclarator declarator, private static IType createAutoParameterType(IASTDeclSpecifier declSpec, IASTDeclarator declarator,