Remove qualifiers from empty struct declarations in output

Empty struct declarations with qualifiers are rejected by NVIDIA GL
driver version 367.27. For example this kind of construct that is
expected to be accepted by the WebGL conformance tests is rejected:

const struct a {
    int i;
};

Since qualifiers do not carry meaning unless a struct declaration
has declarators, they can be simply omitted from the translator
output in this kind of cases to work around this driver issue.

New unit test is added to check that pruning empty declarations works
correctly.

BUG=angleproject:1430
BUG=622492
TEST=WebGL conformance tests, angle_unittests

Change-Id: Id83f83124ae597fcdfa15100d336c2c207d9449c
Reviewed-on: https://chromium-review.googlesource.com/356362
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/PruneEmptyDeclarations.cpp b/src/compiler/translator/PruneEmptyDeclarations.cpp
index ef62dbf..8cbeb7d 100644
--- a/src/compiler/translator/PruneEmptyDeclarations.cpp
+++ b/src/compiler/translator/PruneEmptyDeclarations.cpp
@@ -66,6 +66,27 @@
                     ASSERT(parentAgg != nullptr);
                     mMultiReplacements.push_back(NodeReplaceWithMultipleEntry(parentAgg, node, emptyReplacement));
                 }
+                else if (sym->getType().getQualifier() != EvqGlobal &&
+                         sym->getType().getQualifier() != EvqTemporary)
+                {
+                    // We've hit an empty struct declaration with a qualifier, for example like
+                    // this:
+                    // const struct a { int i; };
+                    // NVIDIA GL driver version 367.27 doesn't accept this kind of declarations, so
+                    // we convert the declaration to a regular struct declaration. This is okay,
+                    // since ESSL 1.00 spec section 4.1.8 says about structs that "The optional
+                    // qualifiers only apply to any declarators, and are not part of the type being
+                    // defined for name."
+
+                    if (mInGlobalScope)
+                    {
+                        sym->getTypePointer()->setQualifier(EvqGlobal);
+                    }
+                    else
+                    {
+                        sym->getTypePointer()->setQualifier(EvqTemporary);
+                    }
+                }
             }
         }
         return false;