@@ -831,6 +831,8 @@ void runSemantic(ref SemanticRunInfo semantic, ref Tree tree, Tree parent,
831
831
runSemantic(semantic, c, tree, condition);
832
832
}
833
833
834
+ bool isEnumClass;
835
+ Scope enumClassScope;
834
836
bool isTemplateSpecializationHere;
835
837
foreach (combination; iterateCombinations())
836
838
{
@@ -856,6 +858,9 @@ void runSemantic(ref SemanticRunInfo semantic, ref Tree tree, Tree parent,
856
858
if (wrappperInfo.flags & DeclarationFlags.friend)
857
859
continue ;
858
860
861
+ if (classSpecifierInfo.key.among(" enum class" , " enum struct" ))
862
+ isEnumClass = true ;
863
+
859
864
Tree parent2 = getRealParent(realParent, semantic);
860
865
size_t parent3Index;
861
866
Tree parent3 = getRealParent(parent2, semantic, &parent3Index);
@@ -930,7 +935,8 @@ void runSemantic(ref SemanticRunInfo semantic, ref Tree tree, Tree parent,
930
935
}
931
936
}
932
937
933
- if (tree.nonterminalID == ParserWrapper.nonterminalIDFor! " ClassSpecifier" )
938
+ if (tree.nonterminalID == ParserWrapper.nonterminalIDFor! " ClassSpecifier"
939
+ || (tree.nonterminalID == ParserWrapper.nonterminalIDFor! " EnumSpecifier" && isEnumClass))
934
940
{
935
941
Scope classScope;
936
942
if (tree ! in targetScope.childScopeByTree)
@@ -945,37 +951,42 @@ void runSemantic(ref SemanticRunInfo semantic, ref Tree tree, Tree parent,
945
951
classScope.scopeCondition = semantic.logicSystem.or(classScope.scopeCondition,
946
952
instanceConditionHere);
947
953
}
954
+ if (tree.nonterminalID == ParserWrapper.nonterminalIDFor! " EnumSpecifier" )
955
+ enumClassScope = classScope;
948
956
if (classSpecifierInfo.className ! in targetScope.subScopes)
949
957
targetScope.subScopes[classSpecifierInfo.className] = [];
950
958
targetScope.subScopes[classSpecifierInfo.className].addOnce(
951
959
targetScope.childScopeByTree[tree]);
952
960
classScope.className.add(ppVersion.condition,
953
961
classSpecifierInfo.className, semantic.logicSystem);
954
962
955
- size_t startIndex = 0 ;
956
- foreach (s; templateScopes)
957
- startIndex = classScope.extraParentScopes.add(ppVersion.condition,
958
- ExtraScope(ExtraScopeType.template_, s), ppVersion.logicSystem, startIndex)
959
- + 1 ;
960
- foreach (t; classSpecifierInfo.parentTypes)
963
+ if (tree.nonterminalID == ParserWrapper.nonterminalIDFor! " ClassSpecifier" )
961
964
{
962
- t = chooseType(t, ppVersion, true );
963
- if (t.kind == TypeKind.record)
965
+ size_t startIndex = 0 ;
966
+ foreach (s; templateScopes)
967
+ startIndex = classScope.extraParentScopes.add(ppVersion.condition,
968
+ ExtraScope(ExtraScopeType.template_, s), ppVersion.logicSystem, startIndex)
969
+ + 1 ;
970
+ foreach (t; classSpecifierInfo.parentTypes)
964
971
{
965
- RecordType recordType = cast (RecordType) t.type;
972
+ t = chooseType(t, ppVersion, true );
973
+ if (t.kind == TypeKind.record)
974
+ {
975
+ RecordType recordType = cast (RecordType) t.type;
966
976
967
- Scope scope_ = scopeForRecord(recordType, ppVersion, semantic);
977
+ Scope scope_ = scopeForRecord(recordType, ppVersion, semantic);
968
978
969
- if (scope_ ! is null && scope_.tree ! is tree)
970
- startIndex = classScope.extraParentScopes.add(ppVersion.condition,
971
- ExtraScope(ExtraScopeType.parentClass, scope_),
972
- ppVersion.logicSystem, startIndex) + 1 ;
979
+ if (scope_ ! is null && scope_.tree ! is tree)
980
+ startIndex = classScope.extraParentScopes.add(ppVersion.condition,
981
+ ExtraScope(ExtraScopeType.parentClass, scope_),
982
+ ppVersion.logicSystem, startIndex) + 1 ;
983
+ }
973
984
}
985
+ if (classSpecifierInfo.namespaces.length && targetScope2 ! is null )
986
+ startIndex = classScope.extraParentScopes.add(ppVersion.condition,
987
+ ExtraScope(ExtraScopeType.namespace, targetScope2),
988
+ ppVersion.logicSystem, startIndex) + 1 ;
974
989
}
975
- if (classSpecifierInfo.namespaces.length && targetScope2 ! is null )
976
- startIndex = classScope.extraParentScopes.add(ppVersion.condition,
977
- ExtraScope(ExtraScopeType.namespace, targetScope2),
978
- ppVersion.logicSystem, startIndex) + 1 ;
979
990
}
980
991
981
992
DeclarationKey dk;
@@ -992,6 +1003,8 @@ void runSemantic(ref SemanticRunInfo semantic, ref Tree tree, Tree parent,
992
1003
dk.flags |= DeclarationFlags.friend;
993
1004
if (targetScope.currentlyInsideParams)
994
1005
dk.flags |= DeclarationFlags.templateParam;
1006
+ if (isEnumClass)
1007
+ dk.flags |= DeclarationFlags.enumClass;
995
1008
dk.name = classSpecifierInfo.className;
996
1009
dk.scope_ = targetScope;
997
1010
@@ -1059,9 +1072,22 @@ void runSemantic(ref SemanticRunInfo semantic, ref Tree tree, Tree parent,
1059
1072
}
1060
1073
}
1061
1074
1062
- foreach ( ref c; tree.childs[headChilds .. $] )
1075
+ if ( tree.nonterminalID == ParserWrapper.nonterminalIDFor ! " EnumSpecifier " && enumClassScope ! is null )
1063
1076
{
1064
- runSemantic(semantic, c, tree, condition);
1077
+ SemanticRunInfo semanticRun = semantic;
1078
+ semanticRun.currentScope = enumClassScope;
1079
+
1080
+ foreach (ref c; tree.childs[headChilds .. $])
1081
+ {
1082
+ runSemantic(semanticRun, c, tree, condition);
1083
+ }
1084
+ }
1085
+ else
1086
+ {
1087
+ foreach (ref c; tree.childs[headChilds .. $])
1088
+ {
1089
+ runSemantic(semantic, c, tree, condition);
1090
+ }
1065
1091
}
1066
1092
}, (MatchNonterminals! (" OriginalNamespaceDefinition" )) {
1067
1093
string name = tree.childs[2 ].content;
0 commit comments