Names of built-in functions cannot be redeclared as functions

With ESSL 3.00, names of built-in functions cannot be redeclared as
functions, and therefore an error needs to be generated if a built-in
function is overloaded.

This is fixed by inserting unmangled built-ins into a special set in
the symbol table and checking if function declarations match any of
the built-ins in the set.

The regular symbol table structures can't be used for storing the
unmangled names because that interferes with name hashing in
OutputGLSL.

Credit goes to Arun Patole, apatole@nvidia.com for initially
investigating this issue and developing the first version of the
patch.

BUG=angleproject:1066
TEST=angle_unittests,
dEQP-GLES3.functional.shaders.functions.invalid.overload_builtin_function*
(2 tests started passing with this change)

Change-Id: I28c8325f5a3a8f4a97226b0dfdbb9762724fa609
Reviewed-on: https://chromium-review.googlesource.com/328994
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: 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 235351c..7f67daa 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -2117,7 +2117,16 @@
     //
     TFunction *prevDec =
         static_cast<TFunction *>(symbolTable.find(function->getMangledName(), getShaderVersion()));
-    if (prevDec)
+
+    if (getShaderVersion() >= 300 && symbolTable.hasUnmangledBuiltIn(function->getName().c_str()))
+    {
+        // With ESSL 3.00, names of built-in functions cannot be redeclared as functions.
+        // Therefore overloading or redefining builtin functions is an error.
+        error(location, "Name of a built-in function cannot be redeclared as function",
+              function->getName().c_str());
+        recover();
+    }
+    else if (prevDec)
     {
         if (prevDec->getReturnType() != function->getReturnType())
         {