Skip to content

Commit a805756

Browse files
authored
Check decl nesting for namespaces. (#5910)
1 parent abeb375 commit a805756

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

source/slang/slang-parser.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -4634,14 +4634,6 @@ static void CompleteDecl(
46344634
ContainerDecl* containerDecl,
46354635
Modifiers modifiers)
46364636
{
4637-
4638-
// If this is a namespace and already added, we don't want to add to the parent
4639-
// Or add any modifiers
4640-
if (as<NamespaceDecl>(decl) && decl->parentDecl)
4641-
{
4642-
return;
4643-
}
4644-
46454637
// Add any modifiers we parsed before the declaration to the list
46464638
// of modifiers on the declaration itself.
46474639
//
@@ -4699,6 +4691,13 @@ static void CompleteDecl(
46994691
}
47004692
}
47014693

4694+
// If this is a namespace and already added, we don't want to add to the parent
4695+
// Or add any modifiers
4696+
if (as<NamespaceDecl>(decl) && decl->parentDecl)
4697+
{
4698+
return;
4699+
}
4700+
47024701
if (!as<GenericDecl>(containerDecl))
47034702
{
47044703
// Make sure the decl is properly nested inside its lexical parent
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -target spirv
2+
3+
struct Type
4+
{
5+
// CHECK: ([[# @LINE+1]]): error 30102:
6+
namespace ns {}
7+
}

0 commit comments

Comments
 (0)