Validate empty statements in switch statements

Even an empty statement like ";" is a statement according to the
grammar. They should not be allowed in switch statements before the
first case statement, but on the other hand a switch statement that
has just an empty statement after the last statement is valid.

Now the parser creates AST nodes from empty statements so that we can
validate switch statements correctly. However, they are pruned shortly
after parsing completes in PruneNoOps, so they don't affect further
processing of the AST.

BUG=angleproject:2181
TEST=angle_unittests

Change-Id: I1085056fc34b146142546fc5f2b7f3124b910ab9
Reviewed-on: https://chromium-review.googlesource.com/743621
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 15a9cd6..adec619 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2701,6 +2701,15 @@
     }
 }
 
+TIntermNode *TParseContext::addEmptyStatement(const TSourceLoc &location)
+{
+    // It's simpler to parse an empty statement as a constant expression rather than having a
+    // different type of node just for empty statements, that will be pruned from the AST anyway.
+    TIntermNode *node = CreateZeroNode(TType(EbtInt, EbpMedium));
+    node->setLine(location);
+    return node;
+}
+
 void TParseContext::setAtomicCounterBindingDefaultOffset(const TPublicType &publicType,
                                                          const TSourceLoc &location)
 {