mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix bogus detection of knr-style function declarator, bug 221567.
This commit is contained in:
parent
508d3c6c86
commit
c544d8f156
2 changed files with 32 additions and 1 deletions
|
@ -4765,4 +4765,34 @@ public class AST2Tests extends AST2BaseTest {
|
||||||
parseAndCheckBindings(code, ParserLanguage.C, true);
|
parseAndCheckBindings(code, ParserLanguage.C, true);
|
||||||
parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
parseAndCheckBindings(code, ParserLanguage.CPP, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// typedef void VOID;
|
||||||
|
// VOID func(VOID) {
|
||||||
|
// }
|
||||||
|
public void testTypedefVoid_Bug221567() throws Exception {
|
||||||
|
final boolean[] isCpps= {false, true};
|
||||||
|
String code= getAboveComment();
|
||||||
|
for (boolean isCpp : isCpps) {
|
||||||
|
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), isCpp);
|
||||||
|
ITypedef td= ba.assertNonProblem("VOID;", 4, ITypedef.class);
|
||||||
|
IBinding ref= ba.assertNonProblem("VOID)", 4);
|
||||||
|
assertSame(td, ref);
|
||||||
|
|
||||||
|
IFunction func= ba.assertNonProblem("func", 4, IFunction.class);
|
||||||
|
IFunctionType ft= func.getType();
|
||||||
|
IType rt= ft.getReturnType();
|
||||||
|
IType[] pts= ft.getParameterTypes();
|
||||||
|
assertEquals(1, pts.length);
|
||||||
|
IType pt = pts[0];
|
||||||
|
assertInstance(rt, ITypedef.class);
|
||||||
|
assertInstance(pt, ITypedef.class);
|
||||||
|
rt= ((ITypedef)rt).getType();
|
||||||
|
pt= ((ITypedef)pt).getType();
|
||||||
|
|
||||||
|
assertTrue(rt instanceof IBasicType);
|
||||||
|
assertEquals(IBasicType.t_void, ((IBasicType)rt).getType());
|
||||||
|
assertTrue(pt instanceof IBasicType);
|
||||||
|
assertEquals(IBasicType.t_void, ((IBasicType)pt).getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2208,7 +2208,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
// if the next token is a tSEMI then the declaration was a regular
|
// if the next token is a tSEMI then the declaration was a regular
|
||||||
// declaration statement i.e. int f(type_def);
|
// declaration statement i.e. int f(type_def);
|
||||||
if (LT(1) == IToken.tSEMI) {
|
final int lt1= LT(1);
|
||||||
|
if (lt1 == IToken.tSEMI || lt1 == IToken.tLBRACE) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue