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$
|
||||||
writer.write( "} \n"); //$NON-NLS-1$
|
writer.write( "} \n"); //$NON-NLS-1$
|
||||||
|
|
||||||
try {
|
parseGCC( writer.toString() );
|
||||||
parseGCC( writer.toString() ); // TODO Devin raised bug 93980
|
parseGPP( writer.toString() );
|
||||||
assertFalse(true);
|
|
||||||
} catch (Exception e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug74190_g_return_if_fail() throws Exception {
|
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$
|
||||||
writer.write( "} \n"); //$NON-NLS-1$
|
writer.write( "} \n"); //$NON-NLS-1$
|
||||||
|
|
||||||
try {
|
parseGCC( writer.toString() );
|
||||||
parseGCC( writer.toString() ); // TODO Devin raised bug 93982
|
parseGPP( writer.toString() );
|
||||||
assertFalse(true);
|
|
||||||
} catch (Exception e) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBug95635() throws Exception{
|
public void testBug95635() throws Exception{
|
||||||
|
|
|
@ -816,6 +816,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
consume();
|
consume();
|
||||||
IASTTypeId typeId = null;
|
IASTTypeId typeId = null;
|
||||||
IASTExpression castExpression = null;
|
IASTExpression castExpression = null;
|
||||||
|
boolean proper=false;
|
||||||
|
IToken startCastExpression=null;
|
||||||
// If this isn't a type name, then we shouldn't be here
|
// If this isn't a type name, then we shouldn't be here
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
@ -823,6 +825,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case IToken.tRPAREN:
|
case IToken.tRPAREN:
|
||||||
consume();
|
consume();
|
||||||
|
proper=true;
|
||||||
|
startCastExpression=mark();
|
||||||
castExpression = castExpression();
|
castExpression = castExpression();
|
||||||
break;
|
break;
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
|
@ -831,6 +835,18 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
} catch (BacktrackException bte) {
|
} 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);
|
backup(mark);
|
||||||
throwBacktrack(bte);
|
throwBacktrack(bte);
|
||||||
}
|
}
|
||||||
|
|
|
@ -907,12 +907,16 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
templateIdScopes.push(IToken.tLPAREN);
|
templateIdScopes.push(IToken.tLPAREN);
|
||||||
}
|
}
|
||||||
boolean popped = false;
|
boolean popped = false;
|
||||||
|
boolean proper=false;
|
||||||
IASTTypeId typeId = null;
|
IASTTypeId typeId = null;
|
||||||
|
IToken startCastExpression=null;
|
||||||
// If this isn't a type name, then we shouldn't be here
|
// If this isn't a type name, then we shouldn't be here
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
typeId = typeId(false);
|
typeId = typeId(false);
|
||||||
consume(IToken.tRPAREN);
|
consume(IToken.tRPAREN);
|
||||||
|
proper = true;
|
||||||
|
startCastExpression=mark();
|
||||||
} catch (BacktrackException bte) {
|
} catch (BacktrackException bte) {
|
||||||
backup(mark);
|
backup(mark);
|
||||||
throwBacktrack(bte);
|
throwBacktrack(bte);
|
||||||
|
@ -922,12 +926,26 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
templateIdScopes.pop();
|
templateIdScopes.pop();
|
||||||
popped = true;
|
popped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTExpression castExpression = castExpression();
|
IASTExpression castExpression = castExpression();
|
||||||
|
|
||||||
mark = null; // clean up mark so that we can garbage collect
|
mark = null; // clean up mark so that we can garbage collect
|
||||||
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
return buildTypeIdUnaryExpression(IASTCastExpression.op_cast,
|
||||||
typeId, castExpression, startingOffset,
|
typeId, castExpression, startingOffset,
|
||||||
calculateEndOffset(castExpression));
|
calculateEndOffset(castExpression));
|
||||||
} catch (BacktrackException b) {
|
} 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);
|
backup(mark);
|
||||||
if (templateIdScopes.size() > 0 && !popped) {
|
if (templateIdScopes.size() > 0 && !popped) {
|
||||||
templateIdScopes.pop();
|
templateIdScopes.pop();
|
||||||
|
|
Loading…
Add table
Reference in a new issue