@@ -899,6 +899,7 @@ bool cxxParserParseEnum(void)
899899 int iCorkQueueIndex = CORK_NIL ;
900900 int iCorkQueueIndexFQ = CORK_NIL ;
901901
902+ bool bEnumExported = false;
902903 if (tag )
903904 {
904905 // FIXME: this is debatable
@@ -921,7 +922,13 @@ bool cxxParserParseEnum(void)
921922 if (bIsScopedEnum )
922923 uProperties |= CXXTagPropertyScopedEnum ;
923924 if (g_cxx .uKeywordState & CXXParserKeywordStateSeenExport )
925+ {
924926 uProperties |= CXXTagPropertyExport ;
927+ bEnumExported = true;
928+ }
929+ tag -> isFileScope = (bEnumExported || cxxScopeIsExported ())
930+ ? 0
931+ : tag -> isFileScope ;
925932
926933 if (uProperties )
927934 pszProperties = cxxTagSetProperties (uProperties );
@@ -936,7 +943,7 @@ bool cxxParserParseEnum(void)
936943 cxxTokenDestroy (pTypeName );
937944 }
938945
939- cxxScopePush (pEnumName ,CXXScopeTypeEnum ,CXXScopeAccessPublic );
946+ cxxScopePushExported (pEnumName ,CXXScopeTypeEnum ,CXXScopeAccessPublic , bEnumExported );
940947 iPushedScopes ++ ;
941948
942949 vString * pScopeName = cxxScopeGetFullNameAsString ();
@@ -968,7 +975,10 @@ bool cxxParserParseEnum(void)
968975 tag = cxxTagBegin (CXXTagKindENUMERATOR ,pFirst );
969976 if (tag )
970977 {
971- tag -> isFileScope = !isInputHeaderFile ();
978+ // If the enum is export'ed, we consider that its
979+ // enumerators are not limited in a file scope.
980+ tag -> isFileScope = !isInputHeaderFile () && !cxxScopeIsExported ();
981+
972982 cxxTagCommit (NULL );
973983 }
974984 }
@@ -1349,6 +1359,7 @@ static bool cxxParserParseClassStructOrUnionInternal(
13491359 bool bGotTemplate = g_cxx .pTemplateTokenChain &&
13501360 (g_cxx .pTemplateTokenChain -> iCount > 0 ) &&
13511361 cxxParserCurrentLanguageIsCPP ();
1362+ bool bExported = uInitialKeywordState & CXXParserKeywordStateSeenExport ;
13521363
13531364 if (tag )
13541365 {
@@ -1400,8 +1411,14 @@ static bool cxxParserParseClassStructOrUnionInternal(
14001411 tag -> isFileScope = !isInputHeaderFile ();
14011412
14021413 unsigned int uProperties = 0 ;
1403- if (uInitialKeywordState & CXXParserKeywordStateSeenExport )
1414+ if (bExported )
14041415 uProperties |= CXXTagPropertyExport ;
1416+ // Overwrite the assigned value if the language object is export'ed
1417+ // directly or indirectly.
1418+ tag -> isFileScope = (bExported || cxxScopeIsExported ())
1419+ ? 0
1420+ : tag -> isFileScope ;
1421+
14051422 vString * pszProperties = NULL ;
14061423
14071424 if (uProperties )
@@ -1413,11 +1430,12 @@ static bool cxxParserParseClassStructOrUnionInternal(
14131430 vStringDelete (pszProperties ); /* NULL is acceptable. */
14141431 }
14151432
1416- cxxScopePush (
1433+ cxxScopePushExported (
14171434 pClassName ,
14181435 uScopeType ,
14191436 (uTagKind == CXXTagCPPKindCLASS ) ?
1420- CXXScopeAccessPrivate : CXXScopeAccessPublic
1437+ CXXScopeAccessPrivate : CXXScopeAccessPublic ,
1438+ bExported
14211439 );
14221440
14231441 if (
0 commit comments