diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java index 7a76a99536e..d092f6dfb71 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java @@ -7017,4 +7017,15 @@ public class AST2Tests extends AST2BaseTest { parseAndCheckBindings(code, ParserLanguage.C); parseAndCheckBindings(code, ParserLanguage.CPP); } + + // void f1(const int* p); + // void f2(const int* p) {} + public void testDroppingOfStorageDecl_293322() throws Exception { + final String code = getAboveComment(); + BindingAssertionHelper bh= new BindingAssertionHelper(code, false); + IFunction f= bh.assertNonProblem("f1", 2); + assertEquals("const int *", ASTTypeUtil.getType(f.getParameters()[0].getType())); + f= bh.assertNonProblem("f2", 2); + assertEquals("const int *", ASTTypeUtil.getType(f.getParameters()[0].getType())); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index ffd03b364d6..ae81f8d85b3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.IASTStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IArrayType; +import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; @@ -651,7 +652,7 @@ public class CVisitor extends ASTQueries { } catch (DOMException e) { } - return new CBasicType(Kind.eInt, CBasicType.IS_UNSIGNED | CBasicType.IS_LONG, expr); + return new CBasicType(Kind.eInt, IBasicType.IS_UNSIGNED | IBasicType.IS_LONG, expr); } static IType getSize_T(IASTExpression expr) { @@ -663,7 +664,7 @@ public class CVisitor extends ASTQueries { } } catch (DOMException e) { } - return new CBasicType(Kind.eInt, CBasicType.IS_LONG | CBasicType.IS_UNSIGNED); + return new CBasicType(Kind.eInt, IBasicType.IS_LONG | IBasicType.IS_UNSIGNED); } static IType unwrapTypedefs(IType type) { @@ -1259,16 +1260,7 @@ public class CVisitor extends ASTQueries { boolean isParameter = (node instanceof IASTParameterDeclaration || node.getParent() instanceof ICASTKnRFunctionDeclarator); - IType type = null; - - //C99 6.7.5.3-12 The storage class specifier for a parameter declaration is ignored unless the declared parameter is one of the - //members of the parameter type list for a function definition. - if (isParameter && node.getParent().getParent() instanceof IASTFunctionDefinition) { - type = createBaseType(declSpec); - } else { - type = createType((ICASTDeclSpecifier) declSpec); - } - + IType type = createType((ICASTDeclSpecifier) declSpec); type = createType(type, declarator);