Skip to content
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] <...> lowers to unnamed pack #708

Closed
JohelEGP opened this issue Sep 26, 2023 · 2 comments
Closed

[BUG] <...> lowers to unnamed pack #708

JohelEGP opened this issue Sep 26, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

Title: <...> lowers to unnamed pack.

Description:

Since commit 025d7af, ... is an identifier.
So ... in a template-parameter-declaration-list lowers to typename ...,
just like T would lower to typename T.

Feature or bug?
I call bug.
#603 makes it so that template template parameters are emitted.
Because it chooses to lower them unnamed, it lowers T: <...> to template<typename> class T.
The existing branch in main to print a pack's ellipsis,
if (n.declaration->is_variadic) { (https://github.com/hsutter/cppfront/pull/603/files#diff-e683e1259bbc0d6de7f1fbf797fb772f31a0a1ef2254ec317d15c298102fa3f3R3931)
isn't exercised because it the declaration isn't variadic (it's name just happens to be ...).

Minimal reproducer (https://cpp2.godbolt.org/z/YbzMc3dh3):

f: <...> () = { }
main: () = { }
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp

Expected result: A diagnostic due to naming a declaration ....

Actual result and error:

Program returned: 0
template<typename ...> auto f() -> void{}
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



//=== Cpp2 type definitions and function declarations ===========================

template<typename ...> auto f() -> void;
auto main() -> int;


//=== Cpp2 function definitions =================================================

template<typename ...> auto f() -> void{}
auto main() -> int{}
@JohelEGP JohelEGP added the bug Something isn't working label Sep 26, 2023
@JohelEGP
Copy link
Contributor Author

A simpler reproducer (https://cpp2.godbolt.org/z/Kf8fdWz95):

main: () = {
  ...: int = 0;
}
auto main() -> int{
  int ... {0}; 
}

@hsutter
Copy link
Owner

hsutter commented Sep 28, 2023

Thanks! Yes, that's a bug... fixing now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants