Skip to content

[BUG] UFCS macro broken given object v<a, b> #493

Closed
@JohelEGP

Description

@JohelEGP

Title: UFCS macro broken given object v<a, b>.

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

main: () -> int = std::variant<i8, i8>().index();
Commands:
cppfront -clean-cpp1 main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp

Expected result:

Program returned: 0

Actual result and error:

[[nodiscard]] auto main() -> int { return CPP2_UFCS_0(index, std::variant<cpp2::i8,cpp2::i8>());  }
Cpp2 lowered to Cpp1.
#include "cpp2util.h"


[[nodiscard]] auto main() -> int;

[[nodiscard]] auto main() -> int { return CPP2_UFCS_0(index, std::variant<cpp2::i8,cpp2::i8>());  }

Output.

build/_cppfront/main.cpp:8:84: error: too many arguments provided to function-like macro invocation
    8 | [[nodiscard]] auto main() -> int { return CPP2_UFCS_0(index, std::variant<cpp2::i8,cpp2::i8>());  }
      |                                                                                    ^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:705:9: note: macro 'CPP2_UFCS_0' defined here
  705 | #define CPP2_UFCS_0(FUNCNAME,PARAM1) \
      |         ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions