1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 489876 - Virt-specifier following trailing-return-type

Change-Id: I1c86634cbb69c0e4b2243dc858abe4c048335378
This commit is contained in:
Nathan Ridge 2016-03-24 21:16:57 -04:00
parent 1723662de3
commit cb76eaa873
2 changed files with 22 additions and 2 deletions

View file

@ -10056,6 +10056,16 @@ public class AST2CPPTests extends AST2TestBase {
parseAndCheckBindings();
}
// struct Base {
// virtual bool waldo();
// };
// struct Derived : Base {
// virtual auto waldo() -> bool override;
// };
public void testOverrideSpecifierAfterTrailingReturnType_489876() throws Exception {
parseAndCheckBindings();
}
// struct CHAINER {
// CHAINER const & operator,(int x) const;
// };

View file

@ -4177,8 +4177,18 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
case IToken.tCOLONCOLON:
case IToken.tIDENTIFIER:
case IToken.tCOMPLETION:
if (option.fRequireAbstract)
throwBacktrack(LA(1));
if (option.fRequireAbstract) {
// We might have a virt-specifier following a type-id in a trailing-return-type.
ContextSensitiveTokenType contextSensitiveType = getContextSensitiveType(LA(1));
if (contextSensitiveType == ContextSensitiveTokenType.OVERRIDE ||
contextSensitiveType == ContextSensitiveTokenType.FINAL) {
// In that case, we're done parsing the declarator of the type-id.
break;
} else {
// Otherwise, we have what looks like a name, but we're not expecting one.
throwBacktrack(LA(1));
}
}
final IASTName declaratorName= !option.fRequireSimpleName ? qualifiedName() : identifier();
endOffset= calculateEndOffset(declaratorName);