1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Fixed an NPE.

This commit is contained in:
Sergey Prigogin 2009-01-25 04:13:08 +00:00
parent 82dbef1ccc
commit 1805f2368d

View file

@ -1336,11 +1336,11 @@ public class CPPSemantics {
IASTDeclarator[] declarators = simpleDeclaration.getDeclarators(); IASTDeclarator[] declarators = simpleDeclaration.getDeclarators();
IScope dtorScope= scope; IScope dtorScope= scope;
if (declSpec.isFriend()) { if (declSpec.isFriend()) {
// friends are added to an enclosing scope. They have to be added such that they are // Friends are added to an enclosing scope. They have to be added such that they are
// picked up when this scope is re-populated during ambiguity resolution, while the // picked up when this scope is re-populated during ambiguity resolution, while the
// enclosing scope is left as it is. // enclosing scope is left as it is.
try { try {
while (dtorScope.getKind() == EScopeKind.eClassType) while (dtorScope != null && dtorScope.getKind() == EScopeKind.eClassType)
dtorScope= dtorScope.getParent(); dtorScope= dtorScope.getParent();
} catch (DOMException e) { } catch (DOMException e) {
dtorScope= null; dtorScope= null;
@ -1374,14 +1374,14 @@ public class CPPSemantics {
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) declSpec; ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) declSpec;
specName = compSpec.getName(); specName = compSpec.getName();
// anonymous union or struct (GCC supports anonymous structs too) // Anonymous union or struct (GCC supports anonymous structs too)
if (declarators.length == 0 && specName.getLookupKey().length == 0) { if (declarators.length == 0 && specName.getLookupKey().length == 0) {
IASTDeclaration[] decls = compSpec.getMembers(); IASTDeclaration[] decls = compSpec.getMembers();
for (IASTDeclaration decl : decls) { for (IASTDeclaration decl : decls) {
populateCache(scope, decl); populateCache(scope, decl);
} }
} else { } else {
// collect friends enclosed in nested classes // Collect friends enclosed in nested classes
switch (scope.getKind()) { switch (scope.getKind()) {
case eLocal: case eLocal:
case eGlobal: case eGlobal:
@ -1396,7 +1396,7 @@ public class CPPSemantics {
IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier) declSpec; IASTEnumerationSpecifier enumeration = (IASTEnumerationSpecifier) declSpec;
specName = enumeration.getName(); specName = enumeration.getName();
// check enumerators too // Check enumerators too
IASTEnumerator[] list = enumeration.getEnumerators(); IASTEnumerator[] list = enumeration.getEnumerators();
IASTName tempName; IASTName tempName;
for (IASTEnumerator enumerator : list) { for (IASTEnumerator enumerator : list) {