1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 06:55:23 +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);
IASTDeclSpecifier declSpec = null; IASTNode parent = declarator.getParent();
boolean isPackExpansion= false;
if (parent instanceof IASTSimpleDeclaration) { IASTDeclSpecifier declSpec = null;
declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier(); boolean isPackExpansion= false;
} else if (parent instanceof IASTParameterDeclaration) { if (parent instanceof IASTSimpleDeclaration) {
declSpec = ((IASTParameterDeclaration) parent).getDeclSpecifier(); declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
} else if (parent instanceof IASTFunctionDefinition) { } else if (parent instanceof IASTParameterDeclaration) {
declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier(); declSpec = ((IASTParameterDeclaration) parent).getDeclSpecifier();
} else if (parent instanceof ICPPASTTypeId) { } else if (parent instanceof IASTFunctionDefinition) {
final ICPPASTTypeId typeId = (ICPPASTTypeId) parent; declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier();
declSpec = typeId.getDeclSpecifier(); } else if (parent instanceof ICPPASTTypeId) {
isPackExpansion= typeId.isPackExpansion(); final ICPPASTTypeId typeId = (ICPPASTTypeId) parent;
} else { declSpec = typeId.getDeclSpecifier();
throw new IllegalArgumentException(); isPackExpansion= typeId.isPackExpansion();
} } else {
throw new IllegalArgumentException();
PlaceholderKind placeholder = usesAuto(declSpec); }
if (placeholder != null) {
return createAutoType(declSpec, declarator, flags, placeholder); PlaceholderKind placeholder = usesAuto(declSpec);
} if (placeholder != null) {
return createAutoType(declSpec, declarator, flags, placeholder);
IType type = createType(declSpec); }
type = makeConstIfConstexpr(type, declSpec, declarator);
type = createType(type, declarator); IType type = createType(declSpec);
type = makeConstIfConstexpr(type, declSpec, declarator);
// C++ specification 8.3.4.3 and 8.5.1.4 type = createType(type, declarator);
IASTNode initClause= declarator.getInitializer();
if (initClause instanceof IASTEqualsInitializer) { // C++ specification 8.3.4.3 and 8.5.1.4
initClause= ((IASTEqualsInitializer) initClause).getInitializerClause(); IASTNode initClause= declarator.getInitializer();
} if (initClause instanceof IASTEqualsInitializer) {
if (initClause instanceof IASTInitializerList) { initClause= ((IASTEqualsInitializer) initClause).getInitializerClause();
IType t= SemanticUtil.getNestedType(type, TDEF); }
if (t instanceof IArrayType) { if (initClause instanceof IASTInitializerList) {
IArrayType at= (IArrayType) t; IType t= SemanticUtil.getNestedType(type, TDEF);
if (at.getSize() == null) { if (t instanceof IArrayType) {
type= new CPPArrayType(at.getType(), IntegralValue.create(((IASTInitializerList) initClause).getSize())); IArrayType at= (IArrayType) t;
if (at.getSize() == null) {
type= new CPPArrayType(at.getType(), IntegralValue.create(((IASTInitializerList) initClause).getSize()));
}
} }
} }
if (isPackExpansion) {
type= new CPPParameterPackType(type);
}
return type;
} finally {
CPPSemantics.popLookupPoint();
} }
if (isPackExpansion) {
type= new CPPParameterPackType(type);
}
return type;
} }
private static IType createAutoParameterType(IASTDeclSpecifier declSpec, IASTDeclarator declarator, private static IType createAutoParameterType(IASTDeclSpecifier declSpec, IASTDeclarator declarator,