mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 11:25:35 +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);
|
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 if
|
||||||
// #define IF_P if (
|
// #define IF_P if (
|
||||||
// #define IF_P_T if (1
|
// #define IF_P_T if (1
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
* Mike Kucera (IBM) - bug #206952
|
* Mike Kucera (IBM) - bug #206952
|
||||||
|
@ -837,9 +837,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
if (supportStatementsInExpressions && LT(2) == IToken.tLBRACE) {
|
if (supportStatementsInExpressions && LT(2) == IToken.tLBRACE) {
|
||||||
return compoundStatementExpression();
|
return compoundStatementExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
t = consume();
|
t = consume();
|
||||||
// TODO - do we need to return a wrapper?
|
|
||||||
IASTExpression lhs = expression();
|
IASTExpression lhs = expression();
|
||||||
int finalOffset = 0;
|
int finalOffset = 0;
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
|
@ -850,9 +848,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
default:
|
default:
|
||||||
throwBacktrack(LA(1));
|
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.tIDENTIFIER:
|
||||||
case IToken.tCOMPLETION:
|
case IToken.tCOMPLETION:
|
||||||
case IToken.tEOC:
|
case IToken.tEOC:
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* John Camelon (IBM Corporation) - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
* Ed Swartz (Nokia)
|
* 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
|
* 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
|
* GNU C and C++. From time to time we will make reference to the ANSI ISO
|
||||||
* specifications.
|
* specifications.
|
||||||
*
|
|
||||||
* @author jcamelon
|
|
||||||
*/
|
*/
|
||||||
public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
private static final int DEFAULT_PARM_LIST_SIZE = 4;
|
private static final int DEFAULT_PARM_LIST_SIZE = 4;
|
||||||
|
@ -1431,11 +1429,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
t = consume();
|
t = consume();
|
||||||
int finalOffset= 0;
|
int finalOffset= 0;
|
||||||
IASTExpression lhs= expression();
|
IASTExpression lhs= expression();
|
||||||
if (LT(1) == IToken.tRPAREN) {
|
switch (LT(1)) {
|
||||||
|
case IToken.tRPAREN:
|
||||||
|
case IToken.tEOC:
|
||||||
finalOffset = consume().getEndOffset();
|
finalOffset = consume().getEndOffset();
|
||||||
} else {
|
break;
|
||||||
// missing parenthesis, assume it's there and keep going.
|
default:
|
||||||
finalOffset = LA(1).getOffset();
|
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.tIDENTIFIER:
|
||||||
|
|
Loading…
Add table
Reference in a new issue