mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Devin Steffler.
Bug 93982 - [Parser] GCC extension has 2 syntax errors from old GCCCompleteParseExtensionsTest#testBug74190_g_return_if_fail()
This commit is contained in:
parent
249408c1cb
commit
e10adfd876
3 changed files with 38 additions and 8 deletions
|
@ -269,10 +269,8 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
|||
writer.write( " }); \n"); //$NON-NLS-1$
|
||||
writer.write( "} \n"); //$NON-NLS-1$
|
||||
|
||||
try {
|
||||
parseGCC( writer.toString() ); // TODO Devin raised bug 93980
|
||||
assertFalse(true);
|
||||
} catch (Exception e) {}
|
||||
parseGCC( writer.toString() );
|
||||
parseGPP( writer.toString() );
|
||||
}
|
||||
|
||||
public void testBug74190_g_return_if_fail() throws Exception {
|
||||
|
@ -283,10 +281,8 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
|||
writer.write( " }); \n"); //$NON-NLS-1$
|
||||
writer.write( "} \n"); //$NON-NLS-1$
|
||||
|
||||
try {
|
||||
parseGCC( writer.toString() ); // TODO Devin raised bug 93982
|
||||
assertFalse(true);
|
||||
} catch (Exception e) {}
|
||||
parseGCC( writer.toString() );
|
||||
parseGPP( writer.toString() );
|
||||
}
|
||||
|
||||
public void testBug95635() throws Exception{
|
||||
|
|
|
@ -816,6 +816,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
consume();
|
||||
IASTTypeId typeId = null;
|
||||
IASTExpression castExpression = null;
|
||||
boolean proper=false;
|
||||
IToken startCastExpression=null;
|
||||
// If this isn't a type name, then we shouldn't be here
|
||||
try {
|
||||
try {
|
||||
|
@ -823,6 +825,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
switch (LT(1)) {
|
||||
case IToken.tRPAREN:
|
||||
consume();
|
||||
proper=true;
|
||||
startCastExpression=mark();
|
||||
castExpression = castExpression();
|
||||
break;
|
||||
case IToken.tEOC:
|
||||
|
@ -831,6 +835,18 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
throw backtrack;
|
||||
}
|
||||
} catch (BacktrackException bte) {
|
||||
try {
|
||||
// try a compoundStatementExpression
|
||||
backup(startCastExpression);
|
||||
if (typeId != null && proper && LT(1) == IToken.tLPAREN) {
|
||||
castExpression = compoundStatementExpression();
|
||||
mark = null; // clean up mark so that we can garbage collect
|
||||
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
||||
typeId, castExpression, startingOffset,
|
||||
LT(1) == IToken.tEOC ? LA(1).getEndOffset() : calculateEndOffset(castExpression));
|
||||
}
|
||||
} catch (BacktrackException bte2) {}
|
||||
|
||||
backup(mark);
|
||||
throwBacktrack(bte);
|
||||
}
|
||||
|
|
|
@ -907,12 +907,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
templateIdScopes.push(IToken.tLPAREN);
|
||||
}
|
||||
boolean popped = false;
|
||||
boolean proper=false;
|
||||
IASTTypeId typeId = null;
|
||||
IToken startCastExpression=null;
|
||||
// If this isn't a type name, then we shouldn't be here
|
||||
try {
|
||||
try {
|
||||
typeId = typeId(false);
|
||||
consume(IToken.tRPAREN);
|
||||
proper = true;
|
||||
startCastExpression=mark();
|
||||
} catch (BacktrackException bte) {
|
||||
backup(mark);
|
||||
throwBacktrack(bte);
|
||||
|
@ -922,12 +926,26 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
templateIdScopes.pop();
|
||||
popped = true;
|
||||
}
|
||||
|
||||
IASTExpression castExpression = castExpression();
|
||||
|
||||
mark = null; // clean up mark so that we can garbage collect
|
||||
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
||||
typeId, castExpression, startingOffset,
|
||||
calculateEndOffset(castExpression));
|
||||
} catch (BacktrackException b) {
|
||||
try {
|
||||
// try a compoundStatementExpression
|
||||
backup(startCastExpression);
|
||||
if (typeId != null && proper && LT(1) == IToken.tLPAREN) {
|
||||
IASTExpression castExpression = compoundStatementExpression();
|
||||
mark = null; // clean up mark so that we can garbage collect
|
||||
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
||||
typeId, castExpression, startingOffset,
|
||||
calculateEndOffset(castExpression));
|
||||
}
|
||||
} catch (BacktrackException bte2) {}
|
||||
|
||||
backup(mark);
|
||||
if (templateIdScopes.size() > 0 && !popped) {
|
||||
templateIdScopes.pop();
|
||||
|
|
Loading…
Add table
Reference in a new issue