Closed
Description
Title: Interpolation lowers unparenthesized.
Minimal reproducer (https://cpp2.godbolt.org/z/nzzPsq8n6):
main: () = {
"`(0)$`".clear();
}
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: CPP2_UFCS_0(clear, ("`" + cpp2::to_string(0) + "`"));
Actual result and error: "`" + cpp2::to_string(0) + CPP2_UFCS_0(clear, "`");
Cpp2 lowered to Cpp1:
#define CPP2_USE_SOURCE_LOCATION Yes
//=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
//=== Cpp2 type definitions and function declarations ===========================
auto main() -> int;
//=== Cpp2 function definitions =================================================
auto main() -> int{
"`" + cpp2::to_string(0) + CPP2_UFCS_0(clear, "`");
}
Output:
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:470:44: warning: unused parameter 'where' [-Wunused-parameter]
470 | auto assert_in_bounds(auto&& x, auto&& arg CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT) -> decltype(auto)
| ^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:369:76: note: expanded from macro 'CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT'
369 | #define CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT , std::source_location where = std::source_location::current()
| ^
build/main.cpp:19:42: error: use of undeclared identifier 'clear'
19 | "`" + cpp2::to_string(0) + CPP2_UFCS_0(clear, "`");
| ^
build/main.cpp:19:30: note: in instantiation of function template specialization 'main()::(anonymous class)::operator()<const char (&)[2]>' requested here
19 | "`" + cpp2::to_string(0) + CPP2_UFCS_0(clear, "`");
| ^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:797:2: note: expanded from macro 'CPP2_UFCS_0'
797 | }(PARAM1)
| ^
1 warning and 1 error generated.