Commit b3cd0250 by Chris Mihelich Committed by Copybara-Service

Stop eating an extra E in ParseTemplateArg for some L<type><value>E literals.

PiperOrigin-RevId: 636682763
Change-Id: I9e5fd6827cb780c288ff5af54643ee4fbbaca6d5
parent a7d70c87
...@@ -585,7 +585,7 @@ static bool ParseFunctionParam(State* state); ...@@ -585,7 +585,7 @@ static bool ParseFunctionParam(State* state);
static bool ParseBracedExpression(State *state); static bool ParseBracedExpression(State *state);
static bool ParseExpression(State *state); static bool ParseExpression(State *state);
static bool ParseExprPrimary(State *state); static bool ParseExprPrimary(State *state);
static bool ParseExprCastValue(State *state); static bool ParseExprCastValueAndTrailingE(State *state);
static bool ParseQRequiresClauseExpr(State *state); static bool ParseQRequiresClauseExpr(State *state);
static bool ParseLocalName(State *state); static bool ParseLocalName(State *state);
static bool ParseLocalNameSuffix(State *state); static bool ParseLocalNameSuffix(State *state);
...@@ -1633,7 +1633,7 @@ static bool ParseTemplateArg(State *state) { ...@@ -1633,7 +1633,7 @@ static bool ParseTemplateArg(State *state) {
// ::= L <source-name> [<template-args>] [<expr-cast-value> E] // ::= L <source-name> [<template-args>] [<expr-cast-value> E]
if (ParseLocalSourceName(state) && Optional(ParseTemplateArgs(state))) { if (ParseLocalSourceName(state) && Optional(ParseTemplateArgs(state))) {
copy = state->parse_state; copy = state->parse_state;
if (ParseExprCastValue(state) && ParseOneCharToken(state, 'E')) { if (ParseExprCastValueAndTrailingE(state)) {
return true; return true;
} }
state->parse_state = copy; state->parse_state = copy;
...@@ -2005,7 +2005,7 @@ static bool ParseExprPrimary(State *state) { ...@@ -2005,7 +2005,7 @@ static bool ParseExprPrimary(State *state) {
// The merged cast production. // The merged cast production.
if (ParseOneCharToken(state, 'L') && ParseType(state) && if (ParseOneCharToken(state, 'L') && ParseType(state) &&
ParseExprCastValue(state)) { ParseExprCastValueAndTrailingE(state)) {
return true; return true;
} }
state->parse_state = copy; state->parse_state = copy;
...@@ -2020,7 +2020,7 @@ static bool ParseExprPrimary(State *state) { ...@@ -2020,7 +2020,7 @@ static bool ParseExprPrimary(State *state) {
} }
// <number> or <float>, followed by 'E', as described above ParseExprPrimary. // <number> or <float>, followed by 'E', as described above ParseExprPrimary.
static bool ParseExprCastValue(State *state) { static bool ParseExprCastValueAndTrailingE(State *state) {
ComplexityGuard guard(state); ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false; if (guard.IsTooComplex()) return false;
// We have to be able to backtrack after accepting a number because we could // We have to be able to backtrack after accepting a number because we could
......
...@@ -276,6 +276,14 @@ TEST(Demangle, Clones) { ...@@ -276,6 +276,14 @@ TEST(Demangle, Clones) {
EXPECT_FALSE(Demangle("_ZL3Foov.isra.2.constprop.", tmp, sizeof(tmp))); EXPECT_FALSE(Demangle("_ZL3Foov.isra.2.constprop.", tmp, sizeof(tmp)));
} }
TEST(Demangle, LiteralOfGlobalNamespaceEnumType) {
char tmp[80];
// void f<(E)42>()
EXPECT_TRUE(Demangle("_Z1fIL1E42EEvv", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
// Test the GNU abi_tag extension. // Test the GNU abi_tag extension.
TEST(Demangle, AbiTags) { TEST(Demangle, AbiTags) {
char tmp[80]; 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