Added error output to the preprocessor.

This patch distinguishes preprocessing errors with normal parsing
errors and gives glslangValidator the ability to output preprocessing
errors.
diff --git a/StandAlone/StandAlone.cpp b/StandAlone/StandAlone.cpp
index f61389c..b88d8ad 100644
--- a/StandAlone/StandAlone.cpp
+++ b/StandAlone/StandAlone.cpp
@@ -611,6 +611,8 @@
         messages = (EShMessages)(messages | EShMsgSpvRules);
     if (Options & EOptionVulkanRules)
         messages = (EShMessages)(messages | EShMsgVulkanRules);
+    if (Options & EOptionOutputPreprocessed)
+        messages = (EShMessages)(messages | EShMsgOnlyPreprocessor);
 }
 
 //
@@ -645,13 +647,22 @@
 
 // Outputs the given string, but only if it is non-null and non-empty.
 // This prevents erroneous newlines from appearing.
-void puts_if_non_empty(const char* str)
+void PutsIfNonEmpty(const char* str)
 {
     if (str && str[0]) {
         puts(str);
     }
 }
 
+// Outputs the given string to stderr, but only if it is non-null and non-empty.
+// This prevents erroneous newlines from appearing.
+void StderrIfNonEmpty(const char* str)
+{
+    if (str && str[0]) {
+      fprintf(stderr, "%s\n", str);
+    }
+}
+
 //
 // For linking mode: Will independently parse each item in the worklist, but then put them
 // in the same program and link them together.
@@ -689,8 +700,14 @@
         shader->setStrings(shaderStrings, 1);
         if (Options & EOptionOutputPreprocessed) {
             std::string str;
-            shader->preprocess(&Resources, defaultVersion, ENoProfile, false, false, messages, &str);
-            puts(str.c_str());
+            if (shader->preprocess(&Resources, defaultVersion, ENoProfile,
+                                   false, false, messages, &str)) {
+                PutsIfNonEmpty(str.c_str());
+            } else {
+                CompileFailed = true;
+            }
+            StderrIfNonEmpty(shader->getInfoLog());
+            StderrIfNonEmpty(shader->getInfoDebugLog());
             FreeFileData(shaderStrings);
             continue;
         }
@@ -700,9 +717,9 @@
         program.addShader(shader);
 
         if (! (Options & EOptionSuppressInfolog)) {
-            puts_if_non_empty(workItem->name.c_str());
-            puts_if_non_empty(shader->getInfoLog());
-            puts_if_non_empty(shader->getInfoDebugLog());
+            PutsIfNonEmpty(workItem->name.c_str());
+            PutsIfNonEmpty(shader->getInfoLog());
+            PutsIfNonEmpty(shader->getInfoDebugLog());
         }
 
         FreeFileData(shaderStrings);
@@ -716,8 +733,8 @@
         LinkFailed = true;
 
     if (! (Options & EOptionSuppressInfolog)) {
-        puts_if_non_empty(program.getInfoLog());
-        puts_if_non_empty(program.getInfoDebugLog());
+        PutsIfNonEmpty(program.getInfoLog());
+        PutsIfNonEmpty(program.getInfoDebugLog());
     }
 
     if (Options & EOptionDumpReflection) {
@@ -814,8 +831,8 @@
         for (int w = 0; w < NumWorkItems; ++w) {
             if (Work[w]) {
                 if (printShaderNames)
-                    puts_if_non_empty(Work[w]->name.c_str());
-                puts_if_non_empty(Work[w]->results.c_str());
+                    PutsIfNonEmpty(Work[w]->name.c_str());
+                PutsIfNonEmpty(Work[w]->results.c_str());
                 delete Work[w];
             }
         }
@@ -943,7 +960,8 @@
            "  -G          create SPIR-V binary, under OpenGL semantics; turns on -l;\n"
            "              default file name is <stage>.spv (-o overrides this)\n"
            "  -H          print human readable form of SPIR-V; turns on -V\n"
-           "  -E          print pre-processed GLSL; cannot be used with -l.\n"
+           "  -E          print pre-processed GLSL; cannot be used with -l;\n"
+           "              errors will appear on stderr.\n"
            "  -c          configuration dump;\n"
            "              creates the default configuration file (redirect to a .conf file)\n"
            "  -d          default to desktop (#version 110) when there is no shader #version\n"