diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java index a93c278b44c..74c3044f17d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/prefix/BasicCompletionTest.java @@ -337,4 +337,25 @@ public class BasicCompletionTest extends CompletionTestBase { String[] expected= {"fooBar", "foo_bar"}; checkCompletion(code, false, expected); } + + // void someFunction() { + // int abc[5]; + // sizeof(ab + public void testCompletionInSizeof340664() throws Exception { + String code = getAboveComment(); + String[] expected= {"abc"}; + checkCompletion(code, false, expected); + checkCompletion(code, true, expected); + } + + // typedef int abc; + // struct X { + // X(ab + public void testCompletionInParamlistOfCtor_338949() throws Exception { + String code = getAboveComment(); + String[] expected= {"abc"}; + checkCompletion(code, false, expected); + checkCompletion(code, true, expected); + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java index 74f602a2cfe..81679d19643 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTQueries.java @@ -103,6 +103,9 @@ public class ASTQueries { * Searches for the innermost declarator that contributes the the type declared. */ public static IASTDeclarator findTypeRelevantDeclarator(IASTDeclarator declarator) { + if (declarator == null) + return null; + IASTDeclarator result= findInnermostDeclarator(declarator); while (result.getPointerOperators().length == 0 && !(result instanceof IASTFieldDeclarator) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java index 1ed91896e50..e2b956327dd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java @@ -521,7 +521,7 @@ class ImplicitsAnalysis { private static boolean paramHasTypeReferenceToTheAssociatedClassType(IASTParameterDeclaration dec, String name) { boolean result= false; IASTDeclarator pdtor= ASTQueries.findTypeRelevantDeclarator(dec.getDeclarator()); - if (pdtor.getPointerOperators().length == 1 && + if (pdtor != null && pdtor.getPointerOperators().length == 1 && pdtor.getPointerOperators()[0] instanceof ICPPASTReferenceOperator && pdtor.getParent() == dec && dec.getDeclSpecifier() instanceof ICPPASTNamedTypeSpecifier) {