-
Notifications
You must be signed in to change notification settings - Fork 260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Type of this
can't use the current type beyond its full name
#471
Comments
Is this supposed to work? I can't get it to work in cpp1 either. But if aliases/using moved outside, before class, its fine. |
If you put a type alias before a
class my_time {
public: using rep = cpp2::longdouble;
: public duration The code in the OP is wrong. |
The issue is also relevant when the type of a member-as-base uses the type's template parameters.
|
Title: Type of Description: See #478 (comment), which also applies to the type. Minimal reproducer (https://cpp2.godbolt.org/z/o5YE6n34f):
Commands:cppfront main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp Expected result: I don't know. Maybe make the emitted base type a template. Actual result and error:
Cpp2 lowered to Cpp1://=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
template<typename T> class t;
//=== Cpp2 type definitions and function declarations ===========================
struct t_x_as_base { T x; };
template<typename T> class t: public t_x_as_base, public std::monostate {
};
auto main() -> int;
//=== Cpp2 function definitions =================================================
auto main() -> int{(void) t<cpp2::i32>{}; } |
this
can't be a nested typethis
can't use the current type beyond its full name
I have changed the issue's title to
This works (https://cpp2.godbolt.org/z/xzr8G1roe):
But not attempting to use
That's why I use "full name". |
Members before bases also can't use template parameters.
struct t_x_as_base { T x; };
template<typename T> class t: public t_x_as_base, public T {
};
|
This is similar in theme to #704. |
#471 (comment) now segfaults: https://cpp2.godbolt.org/z/qc8v8h4Wh. |
Title: Type of
this
can't be a nested type.Description:
It's common to alias complicated base types.
Cpp2's member declaration order suggests a nested type could be used for a
this
member.But it's not generally possible for the lowered Cpp1 to make use of it
(it's directly impossible,
and only for the simple cases could
cppfront
recursively replace nested types for their initializer).Minimal reproducer (https://cpp2.godbolt.org/z/vs1abM95E):
Commands:
cppfront -clean-cpp1 main.cpp2 clang++17 -std=c++2b -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp
Expected result:
A well-formed program or a diagnostic by
cppfront
.Actual result and error:
Cpp2 lowered to Cpp1.
The text was updated successfully, but these errors were encountered: