cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] fix(to_cpp1): type alias loses the **pointer** to function type

Open JohelEGP opened this issue 1 year ago • 0 comments
trafficstars

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 avatar Oct 06 '24 11:10 JohelEGP