From a4c64c988ce2374d09d46386f0682b88d8f7b385 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 12 Apr 2017 17:24:34 -0600 Subject: [PATCH] HLSL: Fix #834: Report #version is an illegal command. --- glslang/MachineIndependent/preprocessor/Pp.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/glslang/MachineIndependent/preprocessor/Pp.cpp b/glslang/MachineIndependent/preprocessor/Pp.cpp index 590290bb..e71e79c4 100644 --- a/glslang/MachineIndependent/preprocessor/Pp.cpp +++ b/glslang/MachineIndependent/preprocessor/Pp.cpp @@ -776,8 +776,12 @@ int TPpContext::CPPversion(TPpToken* ppToken) { int token = scanToken(ppToken); - if (errorOnVersion || versionSeen) - parseContext.ppError(ppToken->loc, "must occur first in shader", "#version", ""); + if (errorOnVersion || versionSeen) { + if (parseContext.isReadingHLSL()) + parseContext.ppError(ppToken->loc, "invalid preprocessor command", "#version", ""); + else + parseContext.ppError(ppToken->loc, "must occur first in shader", "#version", ""); + } versionSeen = true; if (token == '\n') {