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] fix(to_cpp1): type alias loses the **pointer** to function type #1298

Open
JohelEGP opened this issue Oct 6, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

JohelEGP commented Oct 6, 2024

Title: fix(to_cpp1): type alias loses the pointer to function type.

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

main: () = {
  f_t: type == * () -> void;
  static_assert(std::is_pointer_v<f_t>);
}
Commands:
cppfront main.cpp2
clang++-18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -Werror=unused-variable -I . main.cpp

Expected result:

using f_t = void(*)();

Actual result and error:

using f_t = void();
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



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

auto main() -> int;

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

auto main() -> int{
  using f_t = void();
  static_assert(std::is_pointer_v<f_t>);
}
Output:
main.cpp2:3:17: error: static assertion failed due to requirement 'std::is_pointer_v<void ()>'
    3 |   static_assert(std::is_pointer_v<f_t>);
      |                 ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.
@JohelEGP JohelEGP added the bug Something isn't working label Oct 6, 2024
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

1 participant