mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-30 21:55:31 +02:00
Syntax error for cast-ambiguity with unusual decl-spec-sequence, bug 251514
This commit is contained in:
parent
e4f3dd764f
commit
da9b11f4b6
3 changed files with 18 additions and 14 deletions
|
@ -5297,6 +5297,14 @@ public class AST2Tests extends AST2BaseTest {
|
|||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true);
|
||||
}
|
||||
|
||||
// int foo = 42;
|
||||
// typedef char StupidType;
|
||||
// StupidType const *bar = (StupidType const*)&foo;
|
||||
public void testUnusualDeclSpecOrdering_Bug251514() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true);
|
||||
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true);
|
||||
}
|
||||
|
||||
// #define IF if
|
||||
// #define IF_P if (
|
||||
// #define IF_P_T if (1
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Ed Swartz (Nokia)
|
||||
* Mike Kucera (IBM) - bug #206952
|
||||
|
@ -837,9 +837,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
if (supportStatementsInExpressions && LT(2) == IToken.tLBRACE) {
|
||||
return compoundStatementExpression();
|
||||
}
|
||||
|
||||
t = consume();
|
||||
// TODO - do we need to return a wrapper?
|
||||
IASTExpression lhs = expression();
|
||||
int finalOffset = 0;
|
||||
switch (LT(1)) {
|
||||
|
@ -850,9 +848,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
default:
|
||||
throwBacktrack(LA(1));
|
||||
}
|
||||
|
||||
return buildUnaryExpression(
|
||||
IASTUnaryExpression.op_bracketedPrimary, lhs, t.getOffset(), finalOffset);
|
||||
return buildUnaryExpression(IASTUnaryExpression.op_bracketedPrimary, lhs, t.getOffset(), finalOffset);
|
||||
case IToken.tIDENTIFIER:
|
||||
case IToken.tCOMPLETION:
|
||||
case IToken.tEOC:
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
* John Camelon (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||
* Ed Swartz (Nokia)
|
||||
|
@ -164,8 +164,6 @@ import org.eclipse.cdt.internal.core.parser.token.TokenFactory;
|
|||
* This is our implementation of the IParser interface, serving as a parser for
|
||||
* GNU C and C++. From time to time we will make reference to the ANSI ISO
|
||||
* specifications.
|
||||
*
|
||||
* @author jcamelon
|
||||
*/
|
||||
public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||
private static final int DEFAULT_PARM_LIST_SIZE = 4;
|
||||
|
@ -1431,11 +1429,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
t = consume();
|
||||
int finalOffset= 0;
|
||||
IASTExpression lhs= expression();
|
||||
if (LT(1) == IToken.tRPAREN) {
|
||||
finalOffset = consume().getEndOffset();
|
||||
} else {
|
||||
// missing parenthesis, assume it's there and keep going.
|
||||
finalOffset = LA(1).getOffset();
|
||||
switch (LT(1)) {
|
||||
case IToken.tRPAREN:
|
||||
case IToken.tEOC:
|
||||
finalOffset = consume().getEndOffset();
|
||||
break;
|
||||
default:
|
||||
throwBacktrack(LA(1));
|
||||
}
|
||||
return buildUnaryExpression(IASTUnaryExpression.op_bracketedPrimary, lhs, t.getOffset(), finalOffset);
|
||||
case IToken.tIDENTIFIER:
|
||||
|
|
Loading…
Add table
Reference in a new issue