From 523e20dc02eeac8a0a25c6b707ce72ce7676805f Mon Sep 17 00:00:00 2001
From: John Kessenich <cepheus@frii.com>
Date: Fri, 10 Mar 2017 18:03:43 -0700
Subject: [PATCH] PP: Recognize the '::' token, and translate appropriately to
 GLSL/HLSL token.

---
 Test/450.vert                                         | 5 +++++
 Test/baseResults/450.vert.out                         | 5 ++++-
 glslang/Include/revision.h                            | 4 ++--
 glslang/MachineIndependent/Scan.cpp                   | 4 ++++
 glslang/MachineIndependent/preprocessor/PpAtom.cpp    | 2 ++
 glslang/MachineIndependent/preprocessor/PpScanner.cpp | 6 ++++++
 glslang/MachineIndependent/preprocessor/PpTokens.h    | 2 ++
 hlsl/hlslTokens.h                                     | 1 +
 8 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/Test/450.vert b/Test/450.vert
index 48da3edb9..0834d165e 100644
--- a/Test/450.vert
+++ b/Test/450.vert
@@ -21,3 +21,8 @@ struct SA { float f[4]; };
 out SA outSA;
 struct SS { float f; S s; };
 out SS outSS;
+
+void foo()
+{
+    SS::f;
+}
diff --git a/Test/baseResults/450.vert.out b/Test/baseResults/450.vert.out
index 86338c761..9dc4e6f14 100644
--- a/Test/baseResults/450.vert.out
+++ b/Test/baseResults/450.vert.out
@@ -2,7 +2,8 @@
 Warning, version 450 is not yet complete; most version-specific features are present, but some are missing.
 ERROR: 0:12: 'out' : cannot be bool 
 ERROR: 0:13: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: outo
-ERROR: 2 compilation errors.  No code generated.
+ERROR: 0:27: '::' : not supported 
+ERROR: 3 compilation errors.  No code generated.
 
 
 Shader version: 450
@@ -20,6 +21,8 @@ ERROR: node is still EOpNull!
 0:9            2 (const int)
 0:9        Constant:
 0:9          4.500000
+0:25  Function Definition: foo( (global void)
+0:25    Function Parameters: 
 0:?   Linker Objects
 0:?     'anon@0' (out block{out 3-element array of float CullDistance gl_CullDistance})
 0:?     'outb' (smooth out bool)
diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h
index c96734ffb..0dd0fe34e 100644
--- a/glslang/Include/revision.h
+++ b/glslang/Include/revision.h
@@ -2,5 +2,5 @@
 // For the version, it uses the latest git tag followed by the number of commits.
 // For the date, it uses the current date (when then script is run).
 
-#define GLSLANG_REVISION "Overload400-PrecQual.1892"
-#define GLSLANG_DATE "09-Mar-2017"
+#define GLSLANG_REVISION "Overload400-PrecQual.1897"
+#define GLSLANG_DATE "10-Mar-2017"
diff --git a/glslang/MachineIndependent/Scan.cpp b/glslang/MachineIndependent/Scan.cpp
index 0e64364e2..8b3a30636 100644
--- a/glslang/MachineIndependent/Scan.cpp
+++ b/glslang/MachineIndependent/Scan.cpp
@@ -701,6 +701,10 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
         case PpAtomDecrement:          return DEC_OP;
         case PpAtomIncrement:          return INC_OP;
 
+        case PpAtomColonColon:
+            parseContext.error(loc, "not supported", "::", "");
+            break;
+
         case PpAtomConstInt:           parserToken->sType.lex.i   = ppToken.ival;       return INTCONSTANT;
         case PpAtomConstUint:          parserToken->sType.lex.i   = ppToken.ival;       return UINTCONSTANT;
         case PpAtomConstInt64:         parserToken->sType.lex.i64 = ppToken.i64val;     return INT64CONSTANT;
diff --git a/glslang/MachineIndependent/preprocessor/PpAtom.cpp b/glslang/MachineIndependent/preprocessor/PpAtom.cpp
index c4904033a..52df3b025 100644
--- a/glslang/MachineIndependent/preprocessor/PpAtom.cpp
+++ b/glslang/MachineIndependent/preprocessor/PpAtom.cpp
@@ -120,6 +120,8 @@ const struct {
     { PpAtomDecrement,      "--" },
     { PpAtomIncrement,      "++" },
 
+    { PpAtomColonColon,     "::" },
+
     { PpAtomDefine,         "define" },
     { PpAtomUndef,          "undef" },
     { PpAtomIf,             "if" },
diff --git a/glslang/MachineIndependent/preprocessor/PpScanner.cpp b/glslang/MachineIndependent/preprocessor/PpScanner.cpp
index 89748fb2f..b9e7a5b54 100644
--- a/glslang/MachineIndependent/preprocessor/PpScanner.cpp
+++ b/glslang/MachineIndependent/preprocessor/PpScanner.cpp
@@ -691,6 +691,12 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
                 pp->parseContext.ppError(ppToken->loc, "End of line in string", "string", "");
             }
             return PpAtomConstString;
+        case ':':
+            ch = getch();
+            if (ch == ':')
+                return PpAtomColonColon;
+            ungetch();
+            return ':';
         }
 
         ch = getch();
diff --git a/glslang/MachineIndependent/preprocessor/PpTokens.h b/glslang/MachineIndependent/preprocessor/PpTokens.h
index 923fd9fa0..ee442d68e 100644
--- a/glslang/MachineIndependent/preprocessor/PpTokens.h
+++ b/glslang/MachineIndependent/preprocessor/PpTokens.h
@@ -117,6 +117,8 @@ enum EFixedAtoms {
     PpAtomDecrement,
     PpAtomIncrement,
 
+    PpAtomColonColon,
+
     PpAtomPaste,
 
     // Constants
diff --git a/hlsl/hlslTokens.h b/hlsl/hlslTokens.h
index 1c8f52834..9923233ab 100755
--- a/hlsl/hlslTokens.h
+++ b/hlsl/hlslTokens.h
@@ -328,6 +328,7 @@ enum EHlslTokenClass {
     EHTokDot,
     EHTokComma,
     EHTokColon,
+    EHTokColonColon,
     EHTokSemicolon,
     EHTokBang,
     EHTokDash,
-- 
GitLab