Disallow structs as scalar/vector constructor arguments
The spec isn't very explicit about disallowing this, but conversions
from structs are not among the conversion constructors or specified
in any other way either.
BUG=angleproject:2036
TEST=angle_unittests
Change-Id: I23f2ceda1d1348cec0d3bba38a7a013275ff84eb
Reviewed-on: https://chromium-review.googlesource.com/514002
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 4615bf3..8ca734f 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -640,6 +640,12 @@
const TIntermTyped *argTyped = arg->getAsTyped();
ASSERT(argTyped != nullptr);
+ if (argTyped->getBasicType() == EbtStruct)
+ {
+ error(line, "a struct cannot be used as a constructor argument for this type",
+ "constructor");
+ return false;
+ }
if (argTyped->getType().isArray())
{
error(line, "constructing from a non-dereferenced array", "constructor");
@@ -655,7 +661,7 @@
{
overFull = true;
}
- if (type.getBasicType() != EbtStruct && !type.isArray() && size >= type.getObjectSize())
+ if (size >= type.getObjectSize())
{
full = true;
}