From a37b3539d94c434c5d74ab524eae2988e48e0756 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 19 Sep 2018 08:32:28 -0700 Subject: Warn when undefined identifier used in preprocessor conditional (#642) This can mask an error when the user either typos a macro name when writing a conditional, or (as was the case for the user who pointed out this issue) they mistakenly assume that a `#define` in an `import`ed file has been made visible to them. This change just adds the warning in the obvious place, with a test code to ensure it triggers. --- source/slang/preprocessor.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/slang/preprocessor.cpp') diff --git a/source/slang/preprocessor.cpp b/source/slang/preprocessor.cpp index 71c6fd4bb..d652d07bb 100644 --- a/source/slang/preprocessor.cpp +++ b/source/slang/preprocessor.cpp @@ -1213,6 +1213,7 @@ static PreprocessorExpressionValue ParseAndEvaluateUnaryExpression(PreprocessorD // An identifier here means it was not defined as a macro (or // it is defined, but as a function-like macro. These should // just evaluate to zero (possibly with a warning) + GetSink(context)->diagnose(token.loc, Diagnostics::undefinedIdentifierInPreprocessorExpression, token.getName()); return 0; } -- cgit v1.2.3