mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 323596: Type representation for references of typedefs.
This commit is contained in:
parent
9f594c8aee
commit
55fd582a63
2 changed files with 25 additions and 1 deletions
|
@ -8860,4 +8860,20 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
String code= getAboveComment();
|
||||
parseAndCheckBindings(code);
|
||||
}
|
||||
|
||||
// typedef int MyType;
|
||||
//
|
||||
// void f(const MyType& val);
|
||||
// void g(MyType& val);
|
||||
public void testTypeString_323596() throws Exception {
|
||||
String code= getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
IFunction f= bh.assertNonProblem("f(", 1);
|
||||
assertEquals("const MyType &", ASTTypeUtil.getType(f.getType().getParameterTypes()[0], false));
|
||||
assertEquals("const int &", ASTTypeUtil.getType(f.getType().getParameterTypes()[0], true));
|
||||
|
||||
IFunction g= bh.assertNonProblem("g(", 1);
|
||||
assertEquals("MyType &", ASTTypeUtil.getType(g.getType().getParameterTypes()[0], false));
|
||||
assertEquals("int &", ASTTypeUtil.getType(g.getType().getParameterTypes()[0], true));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -473,7 +473,15 @@ public class ASTTypeUtil {
|
|||
if (normalize || type instanceof ICPPSpecialization) {
|
||||
// Skip the typedef and proceed with its target type.
|
||||
} else {
|
||||
// Use the typedef and stop
|
||||
// Output reference, qualifier and typedef, then stop.
|
||||
if (ref != null) {
|
||||
types = (IType[]) ArrayUtil.append(IType.class, types, ref);
|
||||
ref= null;
|
||||
}
|
||||
if (cvq != null) {
|
||||
types = (IType[]) ArrayUtil.append(IType.class, types, cvq);
|
||||
cvq= null;
|
||||
}
|
||||
types = (IType[]) ArrayUtil.append(IType.class, types, type);
|
||||
type= null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue