summaryrefslogtreecommitdiffstats
path: root/source/slang/preprocessor.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-10-09 13:38:33 -0700
committerGitHub <noreply@github.com>2017-10-09 13:38:33 -0700
commit06b2192aa2bb6698c863388c5d085ba5b1f28374 (patch)
tree27a959d883adad48652ca9461291fddb64b5a9b9 /source/slang/preprocessor.cpp
parentfe5eef423389b82e7eb2586fb7a16b96afd004f2 (diff)
Preprocessor: fix `undef` and redefinition (#204)
* Preprocessor: fix `undef` and redefinition The logic for `undef` directives was failing to suppress macro expansion when reading the name to un-define, and so it wasn't actually working at all. We didn't notice this because we didn't have a test case, and users hadn't tried it. The logic for `define` had a similar bug, which meant that any attempt to define an already-defined macro would fail with a cryptic error, rather than raising the intended warning. Test cases have been added for both issues, along with the fixes. * fixup: add expected output for tests added
Diffstat (limited to 'source/slang/preprocessor.cpp')
-rw-r--r--source/slang/preprocessor.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/slang/preprocessor.cpp b/source/slang/preprocessor.cpp
index fff3c0fd4..533a81521 100644
--- a/source/slang/preprocessor.cpp
+++ b/source/slang/preprocessor.cpp
@@ -1619,7 +1619,7 @@ static void HandleIncludeDirective(PreprocessorDirectiveContext* context)
static void HandleDefineDirective(PreprocessorDirectiveContext* context)
{
Token nameToken;
- if (!Expect(context, TokenType::Identifier, Diagnostics::expectedTokenInPreprocessorDirective, &nameToken))
+ if (!ExpectRaw(context, TokenType::Identifier, Diagnostics::expectedTokenInPreprocessorDirective, &nameToken))
return;
Name* name = nameToken.getName();
@@ -1701,7 +1701,7 @@ static void HandleDefineDirective(PreprocessorDirectiveContext* context)
static void HandleUndefDirective(PreprocessorDirectiveContext* context)
{
Token nameToken;
- if (!Expect(context, TokenType::Identifier, Diagnostics::expectedTokenInPreprocessorDirective, &nameToken))
+ if (!ExpectRaw(context, TokenType::Identifier, Diagnostics::expectedTokenInPreprocessorDirective, &nameToken))
return;
Name* name = nameToken.getName();