1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

cv-qualifiers in parameter declarations, bug 293322.

This commit is contained in:
Markus Schorn 2009-10-27 12:59:14 +00:00
parent 8217a6eb90
commit cbc078f817
2 changed files with 15 additions and 12 deletions

View file

@ -7017,4 +7017,15 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C); parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP); 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()));
}
} }

View file

@ -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.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IASTTypeId;
import org.eclipse.cdt.core.dom.ast.IArrayType; 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.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration; import org.eclipse.cdt.core.dom.ast.IEnumeration;
@ -651,7 +652,7 @@ public class CVisitor extends ASTQueries {
} catch (DOMException e) { } 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) { static IType getSize_T(IASTExpression expr) {
@ -663,7 +664,7 @@ public class CVisitor extends ASTQueries {
} }
} catch (DOMException e) { } 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) { static IType unwrapTypedefs(IType type) {
@ -1259,16 +1260,7 @@ public class CVisitor extends ASTQueries {
boolean isParameter = (node instanceof IASTParameterDeclaration || node.getParent() instanceof ICASTKnRFunctionDeclarator); boolean isParameter = (node instanceof IASTParameterDeclaration || node.getParent() instanceof ICASTKnRFunctionDeclarator);
IType type = null; IType type = createType((ICASTDeclSpecifier) declSpec);
//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);
}
type = createType(type, declarator); type = createType(type, declarator);