mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 04:15:35 +02:00
Bug 45203. Fixed a bug in handling of pointer-to-typedef function
parameters.
This commit is contained in:
parent
dd21c5ae58
commit
9d234dcfce
2 changed files with 31 additions and 2 deletions
|
@ -195,13 +195,26 @@ public class BindingClassifierTest extends OneSourceMultipleHeadersTestCase {
|
||||||
// f(0);
|
// f(0);
|
||||||
// f(nullptr);
|
// f(nullptr);
|
||||||
// }
|
// }
|
||||||
public void testFunctionCall() throws Exception {
|
public void testFunctionCallWithPointerParameter_1() throws Exception {
|
||||||
IPreferenceStore preferenceStore = getPreferenceStore();
|
IPreferenceStore preferenceStore = getPreferenceStore();
|
||||||
preferenceStore.setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
|
preferenceStore.setValue(PreferenceConstants.FORWARD_DECLARE_FUNCTIONS, true);
|
||||||
assertDefined();
|
assertDefined();
|
||||||
assertDeclared("f", "A");
|
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 {
|
// struct A {
|
||||||
// A(const char* s);
|
// A(const char* s);
|
||||||
// };
|
// };
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class BindingClassifier {
|
||||||
if (canBeDeclared) {
|
if (canBeDeclared) {
|
||||||
// The declared parameter type must be declared. We must explicitly do this here
|
// The declared parameter type must be declared. We must explicitly do this here
|
||||||
// because this type doesn't appear within the AST.
|
// because this type doesn't appear within the AST.
|
||||||
declareType(parameterType);
|
declareTypeExceptTypedefOrNonFixedEnum(parameterType);
|
||||||
} else {
|
} else {
|
||||||
assert argument != null;
|
assert argument != null;
|
||||||
if (argument instanceof IASTExpression) {
|
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.
|
* Adds the given binding to the list of bindings which have to be defined.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue