Commit 6aab06e0 by Geoff Lang Committed by Commit Bot

Don't allow unary operators on void types.

BUG=900058 Change-Id: Ice8976ddd9cbc9c90162cf7fae2b8f91ddcfcef3 Reviewed-on: https://chromium-review.googlesource.com/c/1344590Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 836674c2
...@@ -4962,7 +4962,7 @@ TIntermTyped *TParseContext::createUnaryMath(TOperator op, ...@@ -4962,7 +4962,7 @@ TIntermTyped *TParseContext::createUnaryMath(TOperator op,
case EOpPositive: case EOpPositive:
if (child->getBasicType() == EbtStruct || child->isInterfaceBlock() || if (child->getBasicType() == EbtStruct || child->isInterfaceBlock() ||
child->getBasicType() == EbtBool || child->isArray() || child->getBasicType() == EbtBool || child->isArray() ||
IsOpaqueType(child->getBasicType())) child->getBasicType() == EbtVoid || IsOpaqueType(child->getBasicType()))
{ {
unaryOpError(loc, GetOperatorString(op), child->getType()); unaryOpError(loc, GetOperatorString(op), child->getType());
return nullptr; return nullptr;
......
...@@ -935,6 +935,13 @@ TEST_F(ConstantFoldingTest, FoldIsInfOutOfRangeFloatLiteral) ...@@ -935,6 +935,13 @@ TEST_F(ConstantFoldingTest, FoldIsInfOutOfRangeFloatLiteral)
ASSERT_TRUE(constantFoundInAST(true)); ASSERT_TRUE(constantFoundInAST(true));
} }
// Regression test case of unary + constant folding of a void struct member.
TEST_F(ConstantFoldingTest, VoidStructMember)
{
constexpr const char *kShaderString = "struct U{void t;}n(){+U().t";
ASSERT_FALSE(compile(kShaderString));
}
// Test that floats that are too small to be represented get flushed to zero. // Test that floats that are too small to be represented get flushed to zero.
// ESSL 3.00.6 section 4.1.4 Floats: // ESSL 3.00.6 section 4.1.4 Floats:
// "A value with a magnitude too small to be represented as a mantissa and exponent is converted to // "A value with a magnitude too small to be represented as a mantissa and exponent is converted to
......
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