From 487ef8e15dcc037251b66ad69f281043ca2d5d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20M=C3=BCller?= Date: Mon, 10 Apr 2017 21:47:16 +0200 Subject: [PATCH] Fix issue with trailing return type parser --- src/libclang/function_parser.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libclang/function_parser.cpp b/src/libclang/function_parser.cpp index 576374f..a5e6fe7 100644 --- a/src/libclang/function_parser.cpp +++ b/src/libclang/function_parser.cpp @@ -293,15 +293,18 @@ namespace // check for trailing return type if (detail::skip_if(stream, "->")) { + //detail::print_tokens(context.tu, context.file, stream.cursor()); // this is rather tricky to skip // so loop over all tokens and see if matching keytokens occur // note that this isn't quite correct // use a heuristic to skip brackets, which should be good enough while (!stream.done()) { - if (stream.peek() == "(" || stream.peek() == "[" || stream.peek() == "<" - || stream.peek() == "{") + if (stream.peek() == "(" || stream.peek() == "[" || stream.peek() == "<") detail::skip_brackets(stream); + else if (stream.peek() == "{") + // begin of definition + break; else if (detail::skip_if(stream, "override")) { DEBUG_ASSERT(allow_virtual, detail::parse_error_handler{}, stream.cursor(), @@ -313,8 +316,8 @@ namespace } else if (detail::skip_if(stream, "final")) { - DEBUG_ASSERT(allow_virtual, detail::parse_error_handler{}, stream.cursor(), "unexpected token"); + DEBUG_ASSERT(allow_virtual, detail::parse_error_handler{}, stream.cursor(), if (result.virtual_keywords) result.virtual_keywords.value() |= cpp_virtual_flags::final; else