Shaders should fail compile if a boolean's precision is specified

Tested and no regression on WebGL conformance 1.0.3

BUG=angle:628
BUG=368874
TEST=http://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/boolean_precision.html

Change-Id: Ie74616c3ab846eea19f4bd4a041fc0f00d55f151
Reviewed-on: https://chromium-review.googlesource.com/198884
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
Tested-by: Zhenyao Mo <zmo@chromium.org>
diff --git a/src/compiler/translator/BaseTypes.h b/src/compiler/translator/BaseTypes.h
index 9bac788..ba9ef5e 100644
--- a/src/compiler/translator/BaseTypes.h
+++ b/src/compiler/translator/BaseTypes.h
@@ -289,6 +289,11 @@
     return false;
 }
 
+inline bool SupportsPrecision(TBasicType type)
+{
+    return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
+}
+
 //
 // Qualifiers and built-ins.  These are mainly used to see what can be read
 // or written, and by the machine dependent translator to know which registers
diff --git a/src/compiler/translator/SymbolTable.h b/src/compiler/translator/SymbolTable.h
index e661c5d..04147d2 100644
--- a/src/compiler/translator/SymbolTable.h
+++ b/src/compiler/translator/SymbolTable.h
@@ -377,7 +377,7 @@
     void dump(TInfoSink &infoSink) const;
 
     bool setDefaultPrecision(const TPublicType& type, TPrecision prec) {
-        if (!supportsPrecision(type.type))
+        if (!SupportsPrecision(type.type))
             return false;
         if (type.isAggregate())
             return false; // Not allowed to set for aggregate types
@@ -389,7 +389,7 @@
     // Searches down the precisionStack for a precision qualifier for the specified TBasicType
     TPrecision getDefaultPrecision( TBasicType type){
 
-        if (!supportsPrecision(type))
+        if (!SupportsPrecision(type))
             return EbpUndefined;
 
         // unsigned integers use the same precision as signed
@@ -413,11 +413,6 @@
 private:
     ESymbolLevel currentLevel() const { return static_cast<ESymbolLevel>(table.size() - 1); }
 
-    bool supportsPrecision(TBasicType type) {
-      // Only supports precision for int, float, and sampler types.
-      return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
-    }
-
     std::vector<TSymbolTableLevel*> table;
     typedef TMap<TBasicType, TPrecision> PrecisionStackLevel;
     std::vector< PrecisionStackLevel*> precisionStack;
diff --git a/src/compiler/translator/glslang.y b/src/compiler/translator/glslang.y
index 0733e44..304e4a9 100644
--- a/src/compiler/translator/glslang.y
+++ b/src/compiler/translator/glslang.y
@@ -1254,6 +1254,11 @@
     | precision_qualifier type_specifier_no_prec {
         $$ = $2;
         $$.precision = $1;
+
+        if (!SupportsPrecision($2.type) {
+            context->error(@1, "illegal type for precision qualifier", getBasicString($2.type));
+            context->recover();
+        }
     }
     ;
 
diff --git a/src/compiler/translator/glslang_tab.cpp b/src/compiler/translator/glslang_tab.cpp
index 70d46d8..4743696 100644
--- a/src/compiler/translator/glslang_tab.cpp
+++ b/src/compiler/translator/glslang_tab.cpp
@@ -3937,6 +3937,11 @@
     {
         (yyval.interm.type) = (yyvsp[(2) - (2)].interm.type);
         (yyval.interm.type).precision = (yyvsp[(1) - (2)].interm.precision);
+
+        if (!SupportsPrecision((yyvsp[(2) - (2)].interm.type).type)) {
+            context->error((yylsp[(1) - (1)]), "illegal type for precision qualifier", getBasicString((yyvsp[(2) - (2)].interm.type).type));
+            context->recover();
+        }
     }
     break;