Don't mark all macros with double underscores as reserved.

Only __FILE__, __LINE__, __VERSION__ and GL_ES are reserved but it is
still not recommended to use a name with double underscores because it may
be used by the "underlying software layers".

Updated the tests to reflect that it is OK to define macros with double
underscores but it is not valid to make assumptions about their values.

Fixes:
dEQP-GLES2.functional.shaders.preprocessor.basic.identifier_with_double_underscore_vertex
dEQP-GLES2.functional.shaders.preprocessor.basic.identifier_with_double_underscore_fragment

BUG=angleproject:898

Change-Id: I77054d04c9935eedcdbb7304dc0c3b60b53994f9
Reviewed-on: https://chromium-review.googlesource.com/268434
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp
index b38f332..64b48b4 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -118,13 +118,28 @@
 
 bool isMacroNameReserved(const std::string &name)
 {
-    // Names prefixed with "GL_" are reserved.
-    if (name.substr(0, 3) == "GL_")
-        return true;
+    const char *kPredefinedMacros[] =
+    {
+        "__LINE__",
+        "__FILE__",
+        "__VERSION__",
+        "GL_ES",
+    };
+    const size_t kPredefinedMacrosCount = sizeof(kPredefinedMacros) / sizeof(*kPredefinedMacros);
 
-    // Names containing two consecutive underscores are reserved.
-    if (name.find("__") != std::string::npos)
+    for (size_t i = 0; i < kPredefinedMacrosCount; i++)
+    {
+        if (name == kPredefinedMacros[i])
+        {
+            return true;
+        }
+    }
+
+    // Names prefixed with "GL_" are reserved.
+    if (name.compare(0, 3, "GL_") == 0)
+    {
         return true;
+    }
 
     return false;
 }