diff options
| -rw-r--r-- | source/slang/slang-preprocessor.cpp | 23 | ||||
| -rw-r--r-- | tests/preprocessor/include-angle-bracket.slang | 8 | ||||
| -rw-r--r-- | tests/preprocessor/include/include-pragma-once-c.h | 2 |
3 files changed, 28 insertions, 5 deletions
diff --git a/source/slang/slang-preprocessor.cpp b/source/slang/slang-preprocessor.cpp index 9586088a1..b0986f64c 100644 --- a/source/slang/slang-preprocessor.cpp +++ b/source/slang/slang-preprocessor.cpp @@ -2994,10 +2994,25 @@ static void HandleIncludeDirective(PreprocessorDirectiveContext* context) AdvanceRawToken(context); Token pathToken; - if(!Expect(context, TokenType::StringLiteral, Diagnostics::expectedTokenInPreprocessorDirective, &pathToken)) - return; - - String path = getFileNameTokenValue(pathToken); + String path; + if (PeekRawTokenType(context) == TokenType::OpLess) + { + StringBuilder pathSB; + Expect(context, TokenType::OpLess, Diagnostics::expectedTokenInPreprocessorDirective, &pathToken); + while (PeekRawTokenType(context) != TokenType::OpGreater && + PeekRawTokenType(context) != TokenType::EndOfFile) + { + pathSB << AdvanceRawToken(context).getContent(); + } + if (!Expect(context, TokenType::OpGreater, Diagnostics::expectedTokenInPreprocessorDirective)) + return; + path = pathSB.produceString(); + } + else + { + Expect(context, TokenType::StringLiteral, Diagnostics::expectedTokenInPreprocessorDirective, &pathToken); + path = getFileNameTokenValue(pathToken); + } auto directiveLoc = GetDirectiveLoc(context); diff --git a/tests/preprocessor/include-angle-bracket.slang b/tests/preprocessor/include-angle-bracket.slang new file mode 100644 index 000000000..4b89387d4 --- /dev/null +++ b/tests/preprocessor/include-angle-bracket.slang @@ -0,0 +1,8 @@ +//TEST:SIMPLE: +// #include support + +int foo() { return 0; } + +#include <include-a.slang.h> + +int baz() { return bar(); }
\ No newline at end of file diff --git a/tests/preprocessor/include/include-pragma-once-c.h b/tests/preprocessor/include/include-pragma-once-c.h index 5c07d2846..2577591fc 100644 --- a/tests/preprocessor/include/include-pragma-once-c.h +++ b/tests/preprocessor/include/include-pragma-once-c.h @@ -2,4 +2,4 @@ #pragma once -#include "pragma-once-c.h"
\ No newline at end of file +#include "pragma-once-c.h" |
