@@ -209,6 +209,7 @@ typedef struct sTokenInfo {
209209 struct sTokenInfo * secondary ;
210210 unsigned long lineNumber ;
211211 MIOPos filePosition ;
212+ bool anonymous ;
212213} tokenInfo ;
213214
214215/*
@@ -464,6 +465,7 @@ static tokenInfo *newToken (void)
464465 token -> isMethod = false;
465466 token -> lineNumber = getInputLineNumber ();
466467 token -> filePosition = getInputFilePosition ();
468+ token -> anonymous = false;
467469
468470 return token ;
469471}
@@ -484,6 +486,14 @@ static tokenInfo *newTokenFrom (tokenInfo *const token)
484486 return newTokenFromFull (token , true);
485487}
486488
489+ static tokenInfo * newAnonTokenFrom (tokenInfo * const token , unsigned int uTagKind )
490+ {
491+ tokenInfo * result = newTokenFromFull (token , false);
492+ result -> anonymous = true;
493+ anonGenerate (result -> string , "__anon" , uTagKind );
494+ return result ;
495+ }
496+
487497static void deleteToken (tokenInfo * const token )
488498{
489499 if (token != NULL )
@@ -535,6 +545,9 @@ static void makeFortranTag (tokenInfo *const token, tagType tag)
535545 if (token -> tag == TAG_COMMON_BLOCK )
536546 e .lineNumberEntry = canUseLineNumberAsLocator ();
537547
548+ if (token -> anonymous )
549+ markTagExtraBit (& e , XTAG_ANONYMOUS );
550+
538551 e .lineNumber = token -> lineNumber ;
539552 e .filePosition = token -> filePosition ;
540553 e .isFileScope = isFileScope (token -> tag );
@@ -1748,25 +1761,27 @@ static void parseUnionStmt (tokenInfo *const token)
17481761 */
17491762static void parseStructureStmt (tokenInfo * const token )
17501763{
1751- tokenInfo * name ;
1764+ tokenInfo * name = NULL ;
17521765 Assert (isKeyword (token , KEYWORD_structure ));
17531766 readToken (token );
17541767 if (isType (token , TOKEN_OPERATOR ) &&
17551768 strcmp (vStringValue (token -> string ), "/" ) == 0 )
17561769 { /* read structure name */
17571770 readToken (token );
17581771 if (isType (token , TOKEN_IDENTIFIER ))
1759- makeFortranTag (token , TAG_DERIVED_TYPE );
1760- name = newTokenFrom (token );
1772+ {
1773+ name = newTokenFrom (token );
1774+ name -> type = TOKEN_IDENTIFIER ;
1775+ }
17611776 skipPast (token , TOKEN_OPERATOR );
17621777 }
1763- else
1778+ if ( name == NULL )
17641779 { /* fake out anonymous structure */
1765- name = newToken ( );
1780+ name = newAnonTokenFrom ( token , TAG_COMPONENT );
17661781 name -> type = TOKEN_IDENTIFIER ;
17671782 name -> tag = TAG_DERIVED_TYPE ;
1768- vStringCopyS (name -> string , "anonymous" );
17691783 }
1784+ makeFortranTag (name , TAG_DERIVED_TYPE );
17701785 while (isType (token , TOKEN_IDENTIFIER ))
17711786 { /* read field names */
17721787 makeFortranTag (token , TAG_COMPONENT );
@@ -1982,29 +1997,27 @@ static void parseInterfaceBlock (tokenInfo *const token)
19821997 tokenInfo * name = NULL ;
19831998 Assert (isKeyword (token , KEYWORD_interface ));
19841999 readToken (token );
1985- if (isType (token , TOKEN_IDENTIFIER ))
1986- {
1987- makeFortranTag (token , TAG_INTERFACE );
1988- name = newTokenFrom (token );
1989- }
1990- else if (isKeyword (token , KEYWORD_assignment ) ||
2000+ if (isKeyword (token , KEYWORD_assignment ) ||
19912001 isKeyword (token , KEYWORD_operator ))
19922002 {
19932003 readToken (token );
19942004 if (isType (token , TOKEN_PAREN_OPEN ))
19952005 readToken (token );
19962006 if (isType (token , TOKEN_OPERATOR ))
1997- {
1998- makeFortranTag (token , TAG_INTERFACE );
19992007 name = newTokenFrom (token );
2000- }
2008+ }
2009+ else if (isType (token , TOKEN_IDENTIFIER ))
2010+ {
2011+ name = newTokenFrom (token );
2012+ name -> type = TOKEN_IDENTIFIER ;
20012013 }
20022014 if (name == NULL )
20032015 {
2004- name = newToken ( );
2016+ name = newAnonTokenFrom ( token , TAG_INTERFACE );
20052017 name -> type = TOKEN_IDENTIFIER ;
20062018 name -> tag = TAG_INTERFACE ;
20072019 }
2020+ makeFortranTag (name , TAG_INTERFACE );
20082021 ancestorPush (name );
20092022 while (! isKeyword (token , KEYWORD_end ) &&
20102023 ! isType (token , TOKEN_EOF ))
@@ -2054,15 +2067,17 @@ static void parseEnumBlock (tokenInfo *const token)
20542067 if (isType (token , TOKEN_DOUBLE_COLON ))
20552068 readToken (token );
20562069 if (isType (token , TOKEN_IDENTIFIER ))
2070+ {
20572071 name = newTokenFrom (token );
2072+ name -> type = TOKEN_IDENTIFIER ;
2073+ }
20582074 if (name == NULL )
20592075 {
2060- name = newToken ( );
2076+ name = newAnonTokenFrom ( token , TAG_ENUM );
20612077 name -> type = TOKEN_IDENTIFIER ;
20622078 name -> tag = TAG_ENUM ;
20632079 }
2064- else
2065- makeFortranTag (name , TAG_ENUM );
2080+ makeFortranTag (name , TAG_ENUM );
20662081 skipToNextStatement (token );
20672082 ancestorPush (name );
20682083 while (! isKeyword (token , KEYWORD_end ) &&
0 commit comments