Direct inheritance from the same type cpp2::store_as_base<T> multiple times is ill-formed. I suggest its API follows https://www.boost.org/doc/libs/release/libs/utility/doc/html/utility/utilities/base_from_member.html.
Minimal reproducer:
x: type = { }
w: type = {
a: std::string;
b: std::string;
this: x;
}
Commands:
cppfront x.cpp2
clang++17 -std=c++2b -I $CPPFRONT_INCLUDE_DIR x.cppExpected result: A well-formed program.
Actual result and error:
Generated C++1//=== Cpp2 type declarations ==================================================== #include "cpp2util.h" #line 1 "x.cpp2" class x; class w; //=== Cpp2 type definitions and function declarations =========================== #line 1 "x.cpp2" class x {}; class w: private cpp2::store_as_base<std::string>, private cpp2::store_as_base<std::string>, public x { #line 6 "x.cpp2" }; //=== Cpp2 function definitions =================================================
x.cpp2:2:52: error: base class 'cpp2::store_as_base<std::string>' (aka 'store_as_base<basic_string<char>>') specified more than once as a direct base class
class w: private cpp2::store_as_base<std::string>, private cpp2::store_as_base<std::string>, public x {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.