diff options
| -rw-r--r-- | source/slang/slang-parser.cpp | 15 | ||||
| -rw-r--r-- | tests/diagnostics/invalid-namespace-nesting.slang | 7 |
2 files changed, 14 insertions, 8 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp index 5554724a7..10dbe3140 100644 --- a/source/slang/slang-parser.cpp +++ b/source/slang/slang-parser.cpp @@ -4634,14 +4634,6 @@ static void CompleteDecl( 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) - { - return; - } - // Add any modifiers we parsed before the declaration to the list // of modifiers on the declaration itself. // @@ -4699,6 +4691,13 @@ static void CompleteDecl( } } + // 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) + { + return; + } + if (!as<GenericDecl>(containerDecl)) { // Make sure the decl is properly nested inside its lexical parent diff --git a/tests/diagnostics/invalid-namespace-nesting.slang b/tests/diagnostics/invalid-namespace-nesting.slang new file mode 100644 index 000000000..0abb01347 --- /dev/null +++ b/tests/diagnostics/invalid-namespace-nesting.slang @@ -0,0 +1,7 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv + +struct Type +{ + // CHECK: ([[# @LINE+1]]): error 30102: + namespace ns {} +}
\ No newline at end of file |
