Commit dc552fce by Nicolas Capens Committed by Nicolas Capens

Drop the float literal suffix

In GLSL ES 3.00, float literals are allowed to have an 'f' or 'F' suffix, but they don't change the parsing process since they're always interpreted as single-precision IEEE-754 floating-point values. The std::istringstream used for parsing the literal's string can have implementation dependent behavior depending on the presence of the suffix, so this change removes it. This matches what ANGLE does. Fixes: b/168250854 Change-Id: I203833a2e817ca698894db5669941fb435b97868 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/48388 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 41974f57
...@@ -509,7 +509,9 @@ int floatsuffix_check(TParseContext* context) ...@@ -509,7 +509,9 @@ int floatsuffix_check(TParseContext* context)
return 0; return 0;
} }
if (!atof_clamp(yytext, &(yylval->lex.f))) std::string text = yytext;
text.resize(text.size() - 1); // Drop the suffix
if(!atof_clamp(text.c_str(), &(yylval->lex.f)))
yyextra->warning(*yylloc, "Float overflow", yytext, ""); yyextra->warning(*yylloc, "Float overflow", yytext, "");
return(FLOATCONSTANT); return(FLOATCONSTANT);
......
...@@ -3741,7 +3741,9 @@ int floatsuffix_check(TParseContext* context) ...@@ -3741,7 +3741,9 @@ int floatsuffix_check(TParseContext* context)
return 0; return 0;
} }
if (!atof_clamp(yytext, &(yylval->lex.f))) std::string text = yytext;
text.resize(text.size() - 1); // Drop the suffix
if(!atof_clamp(text.c_str(), &(yylval->lex.f)))
yyextra->warning(*yylloc, "Float overflow", yytext, ""); yyextra->warning(*yylloc, "Float overflow", yytext, "");
return(FLOATCONSTANT); return(FLOATCONSTANT);
......
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