Fix out-of-class destructor definition
This commit is contained in:
parent
e6271f4c0d
commit
b5a5e42955
2 changed files with 16 additions and 6 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <cppast/cpp_function.hpp>
|
||||
#include <cppast/cpp_member_function.hpp>
|
||||
#include <clang-c/Index.h>
|
||||
|
||||
#include "libclang_visitor.hpp"
|
||||
#include "parse_functions.hpp"
|
||||
|
|
@ -657,13 +658,15 @@ std::unique_ptr<cpp_entity> detail::parse_cpp_destructor(const detail::parse_con
|
|||
detail::tokenizer tokenizer(context.tu, context.file, cur);
|
||||
detail::token_stream stream(tokenizer, cur);
|
||||
|
||||
auto is_virtual = detail::skip_if(stream, "virtual");
|
||||
detail::skip(stream, "~");
|
||||
auto prefix_info = parse_prefix_info(stream, "~", false);
|
||||
DEBUG_ASSERT(!prefix_info.is_constexpr && !prefix_info.is_explicit, detail::assert_handler{});
|
||||
|
||||
auto name = std::string("~") + stream.get().c_str();
|
||||
cpp_destructor::builder builder(std::move(name));
|
||||
context.comments.match(builder.get(), cur);
|
||||
|
||||
detail::skip(stream, "(");
|
||||
detail::skip(stream, ")");
|
||||
return handle_suffix(context, cur, builder, stream, is_virtual, type_safe::nullopt);
|
||||
return handle_suffix(context, cur, builder, stream, prefix_info.is_virtual,
|
||||
std::move(prefix_info.semantic_parent));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,6 +331,10 @@ struct d : c
|
|||
/// virtual ~d() override final;
|
||||
~d() final;
|
||||
};
|
||||
|
||||
/// virtual d::~d() override;
|
||||
d::~d() {}
|
||||
|
||||
)";
|
||||
|
||||
auto file = parse({}, "cpp_destructor.cpp", code);
|
||||
|
|
@ -364,12 +368,15 @@ struct d : c
|
|||
else if (dtor.name() == "~d")
|
||||
{
|
||||
REQUIRE(dtor.virtual_info());
|
||||
REQUIRE(dtor.virtual_info().value()
|
||||
== (cpp_virtual_flags::override | cpp_virtual_flags::final));
|
||||
if (dtor.is_declaration())
|
||||
REQUIRE(dtor.virtual_info().value()
|
||||
== (cpp_virtual_flags::override | cpp_virtual_flags::final));
|
||||
else
|
||||
REQUIRE(dtor.virtual_info().value() == cpp_virtual_flags::override);
|
||||
REQUIRE(!dtor.noexcept_condition());
|
||||
}
|
||||
else
|
||||
REQUIRE(false);
|
||||
});
|
||||
REQUIRE(count == 4u);
|
||||
REQUIRE(count == 5u);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue