Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-09-27 22:45:42 +0000
committerNathan Ridge2017-09-28 16:13:57 +0000
commit80dc8d9c2517e738be2e16a6f98375266259bd0d (patch)
treead61a1ee1abd2f3dae2e78bad03e2b1d65f7b84d /core/org.eclipse.cdt.core
parentbb9d1db32349d7c217fb2b964e45ee15f4e100cb (diff)
downloadorg.eclipse.cdt-80dc8d9c2517e738be2e16a6f98375266259bd0d.tar.gz
org.eclipse.cdt-80dc8d9c2517e738be2e16a6f98375266259bd0d.tar.xz
org.eclipse.cdt-80dc8d9c2517e738be2e16a6f98375266259bd0d.zip
Bug 513105 - Avoid pushing a null lookup point in CPPVisitor.createType()
ArrayDeque doesn't allow null elements. Change-Id: Ib610cfedf02232d30b4fc4e1b4d4d5ba45d7aee3
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java100
1 files changed, 50 insertions, 50 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index 8e0168cabe7..70329995609 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -2071,65 +2071,65 @@ public class CPPVisitor extends ASTQueries {
public static IType createType(IASTDeclarator declarator) {
// Resolve placeholders by default.
- try {
- CPPSemantics.pushLookupPoint(declarator);
- return createType(declarator, RESOLVE_PLACEHOLDERS);
- } finally {
- CPPSemantics.popLookupPoint();
- }
+ return createType(declarator, RESOLVE_PLACEHOLDERS);
}
public static IType createType(IASTDeclarator declarator, int flags) {
if (declarator == null)
return ProblemType.NO_NAME;
- declarator= findOutermostDeclarator(declarator);
- IASTNode parent = declarator.getParent();
-
- IASTDeclSpecifier declSpec = null;
- boolean isPackExpansion= false;
- if (parent instanceof IASTSimpleDeclaration) {
- declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
- } else if (parent instanceof IASTParameterDeclaration) {
- declSpec = ((IASTParameterDeclaration) parent).getDeclSpecifier();
- } else if (parent instanceof IASTFunctionDefinition) {
- declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier();
- } else if (parent instanceof ICPPASTTypeId) {
- final ICPPASTTypeId typeId = (ICPPASTTypeId) parent;
- declSpec = typeId.getDeclSpecifier();
- isPackExpansion= typeId.isPackExpansion();
- } else {
- throw new IllegalArgumentException();
- }
-
- 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);
-
- // C++ specification 8.3.4.3 and 8.5.1.4
- IASTNode initClause= declarator.getInitializer();
- if (initClause instanceof IASTEqualsInitializer) {
- initClause= ((IASTEqualsInitializer) initClause).getInitializerClause();
- }
- if (initClause instanceof IASTInitializerList) {
- IType t= SemanticUtil.getNestedType(type, TDEF);
- if (t instanceof IArrayType) {
- IArrayType at= (IArrayType) t;
- if (at.getSize() == null) {
- type= new CPPArrayType(at.getType(), IntegralValue.create(((IASTInitializerList) initClause).getSize()));
+ CPPSemantics.pushLookupPoint(declarator);
+ try {
+ declarator= findOutermostDeclarator(declarator);
+ IASTNode parent = declarator.getParent();
+
+ IASTDeclSpecifier declSpec = null;
+ boolean isPackExpansion= false;
+ if (parent instanceof IASTSimpleDeclaration) {
+ declSpec = ((IASTSimpleDeclaration) parent).getDeclSpecifier();
+ } else if (parent instanceof IASTParameterDeclaration) {
+ declSpec = ((IASTParameterDeclaration) parent).getDeclSpecifier();
+ } else if (parent instanceof IASTFunctionDefinition) {
+ declSpec = ((IASTFunctionDefinition) parent).getDeclSpecifier();
+ } else if (parent instanceof ICPPASTTypeId) {
+ final ICPPASTTypeId typeId = (ICPPASTTypeId) parent;
+ declSpec = typeId.getDeclSpecifier();
+ isPackExpansion= typeId.isPackExpansion();
+ } else {
+ throw new IllegalArgumentException();
+ }
+
+ 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);
+
+ // C++ specification 8.3.4.3 and 8.5.1.4
+ IASTNode initClause= declarator.getInitializer();
+ if (initClause instanceof IASTEqualsInitializer) {
+ initClause= ((IASTEqualsInitializer) initClause).getInitializerClause();
+ }
+ if (initClause instanceof IASTInitializerList) {
+ IType t= SemanticUtil.getNestedType(type, TDEF);
+ if (t instanceof IArrayType) {
+ 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,

Back to the top