diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-10-01 18:44:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-10-01 18:44:50 +0000 |
commit | 7fb25418ed726c594ee800378538a96c69e84d4b (patch) | |
tree | ebd4b5fca812482aa6686384f20e5d279d6bc695 /clang/lib/Parse/ParseDeclCXX.cpp | |
parent | f14331f5c32c10ddca43ab4d0b3faff2fdfa1367 (diff) | |
download | bcm5719-llvm-7fb25418ed726c594ee800378538a96c69e84d4b.tar.gz bcm5719-llvm-7fb25418ed726c594ee800378538a96c69e84d4b.zip |
Implement the C++0x "trailing return type" feature, e.g.,
auto f(int) -> int
from Daniel Wallin!
(With a few minor bug fixes from me).
llvm-svn: 115322
Diffstat (limited to 'clang/lib/Parse/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 092268c8215..59d4f9fad39 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1871,6 +1871,25 @@ bool Parser::ParseExceptionSpecification(SourceLocation &EndLoc, return false; } +/// ParseTrailingReturnType - Parse a trailing return type on a new-style +/// function declaration. +TypeResult Parser::ParseTrailingReturnType() { + assert(Tok.is(tok::arrow) && "expected arrow"); + + ConsumeToken(); + + // FIXME: Need to suppress declarations when parsing this typename. + // Otherwise in this function definition: + // + // auto f() -> struct X {} + // + // struct X is parsed as class definition because of the trailing + // brace. + + SourceRange Range; + return ParseTypeName(&Range); +} + /// \brief We have just started parsing the definition of a new class, /// so push that class onto our stack of classes that is currently /// being parsed. |