1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 08:55:25 +02:00

Bug 45203. Fixed a bug in handling of pointer-to-typedef function

parameters.
This commit is contained in:
Sergey Prigogin 2013-08-05 20:31:50 -07:00
parent dd21c5ae58
commit 9d234dcfce
2 changed files with 31 additions and 2 deletions

View file

@ -195,13 +195,26 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
// f(0);
// f(nullptr);
// }
public void testFunctionCall() throws Exception {
public void testFunctionCallWithPointerParameter_1() throws Exception {
IPreferenceStore preferenceStore = getPreferenceStore();
preferenceStore.setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
assertDefined();
assertDeclared("f", "A");
}
// typedef int A;
// void f(const A* p);
// void test() {
// f(nullptr);
// }
public void testFunctionCallWithPointerParameter_2() throws Exception {
IPreferenceStore preferenceStore = getPreferenceStore();
preferenceStore.setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
assertDefined();
assertDeclared("f");
}
// struct A {
// A(const char* s);
// };

View file

@ -201,7 +201,7 @@ public class BindingClassifier {
if (canBeDeclared) {
// The declared parameter type must be declared. We must explicitly do this here
// because this type doesn't appear within the AST.
declareType(parameterType);
declareTypeExceptTypedefOrNonFixedEnum(parameterType);
} else {
assert argument != null;
if (argument instanceof IASTExpression) {
@ -422,6 +422,22 @@ public class BindingClassifier {
}
}
/**
* Adds the given type to the list of bindings which have to be declared. Typedefs and
* enumerations without fixed underlying type are skipped since they must be defined in the file
* that references them by name. If the type is explicitly referenced in this translation unit,
* it will be defined independently from this method.
*
* @param type The type to add.
*/
private void declareTypeExceptTypedefOrNonFixedEnum(IType type) {
IBinding typeBinding = getTypeBinding(type);
if (typeBinding != null && !(typeBinding instanceof ITypedef)
&& !isEnumerationWithoutFixedUnderlyingType(typeBinding)) {
declareBinding(typeBinding);
}
}
/**
* Adds the given binding to the list of bindings which have to be defined.
*