Commit 9140cc7b by Chris Mihelich Committed by Copybara-Service

Demangle complex floating-point literals.

PiperOrigin-RevId: 641324572
Change-Id: Ie266da9c8c702e62b89352d64870fb41d2ea76c3
parent c6000317
......@@ -2476,8 +2476,15 @@ static bool ParseExprCastValueAndTrailingE(State *state) {
}
state->parse_state = copy;
if (ParseFloatNumber(state) && ParseOneCharToken(state, 'E')) {
return true;
if (ParseFloatNumber(state)) {
// <float> for ordinary floating-point types
if (ParseOneCharToken(state, 'E')) return true;
// <float> _ <float> for complex floating-point types
if (ParseOneCharToken(state, '_') && ParseFloatNumber(state) &&
ParseOneCharToken(state, 'E')) {
return true;
}
}
state->parse_state = copy;
......
......@@ -641,6 +641,25 @@ TEST(Demangle, StringLiterals) {
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, ComplexFloatingPointLiterals) {
char tmp[80];
// Source (use g++ -fext-numeric-literals to compile):
//
// using C = double _Complex;
// template <class T> void f(char (&)[sizeof(C{sizeof(T)} + 4.0j)]) {}
// template void f<int>(char (&)[sizeof(C{sizeof(int)} + 4.0j)]);
//
// GNU demangling:
//
// void f<int>(char (&) [sizeof (double _Complex{sizeof (int)}+
// ((double _Complex)0000000000000000_4010000000000000))])
EXPECT_TRUE(Demangle(
"_Z1fIiEvRAszpltlCdstT_ELS0_0000000000000000_4010000000000000E_c",
tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, GlobalInitializers) {
char tmp[80];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment