diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-04-05 17:53:41 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-05 17:53:41 -0400 |
| commit | 464ecb6083f64f903df19b961e2af0075bdf3111 (patch) | |
| tree | 6dbb83f694b175cf8bf71f937c467b1ca27a0f62 /source/slang/slang-parser.cpp | |
| parent | 7f36c34daf633dcade3a3bab9cdcf14a34fed3cd (diff) | |
Fix issue with multiple namespace openings (#2176)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Added sample-grad-clamp-lod sample.
* Fix handling multiple reopenings of namespaces.
Diffstat (limited to 'source/slang/slang-parser.cpp')
| -rw-r--r-- | source/slang/slang-parser.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 961691c9a..c08f5cf34 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -2928,8 +2928,7 @@ namespace Slang // any non-null pointer we return to the AST). // NamespaceDecl* namespaceDecl = nullptr; - NodeBase* result = nullptr; - // + // In order to find out what case we are in, we start by looking // for a namespace declaration of the same name in the parent // declaration. @@ -2985,14 +2984,6 @@ namespace Slang { namespaceDecl = parser->astBuilder->create<NamespaceDecl>(); namespaceDecl->nameAndLoc = nameAndLoc; - - // In the case where we are creating the first - // declaration of the given namesapce, we need - // to use it as the return value of the parsing - // callback, so that it is appropriately added - // to the parent declaration. - // - result = namespaceDecl; } } @@ -3003,7 +2994,7 @@ namespace Slang // parseDeclBody(parser, namespaceDecl); - return result; + return namespaceDecl; } static NodeBase* parseUsingDecl(Parser* parser, void* /*userData*/) @@ -3590,6 +3581,16 @@ namespace Slang ContainerDecl* containerDecl, Modifiers modifiers) { + + // If this is a namespace and already added, we don't want to add to the parent + // Or add any modifiers + if (as<NamespaceDecl>(decl) && decl->parentDecl) + { + // Presumably we have no modifiers. + SLANG_ASSERT(modifiers.isEmpty()); + return; + } + // Add any modifiers we parsed before the declaration to the list // of modifiers on the declaration itself. // @@ -3601,9 +3602,9 @@ namespace Slang declToModify = genericDecl->inner; _addModifiers(declToModify, modifiers); - // Make sure the decl is properly nested inside its lexical parent if (containerDecl) { + // Make sure the decl is properly nested inside its lexical parent AddMember(containerDecl, decl); } } |
