1. senex
  2. cppheaderparser

Commits

senex  committed 607ac97

Fixed bug 3568241: Crash parsing 2 anonymous unions in a struct

Allow multiple variables of the same name if they are anonymous.

  • Participants
  • Parent commits 5387601
  • Branches default

Comments (0)

Files changed (3)

File CppHeaderParser/CppHeaderParser.py

View file
             self.curClass = newClass["name"]
             self._classes_brace_level[ newClass['name'] ] = self.braceDepth
 
-        if not key.endswith("::") and len(key) != 0:
+        if not key.endswith("::") and not key.endswith(" ") and len(key) != 0:
             if key in self.classes:
                 trace_print( 'ERROR name collision:', key )
                 self.classes[key].show()

File CppHeaderParser/test/TestSampleClass.h

View file
 	enum Stem stem_property;
 }
 
-// Bug 3567854
+// Bug 3567854 and 3568241
 struct Beans
 {
     UINT16 hdr;
         UINT16 raw[3];
     };
     UINT32 data[204];
+    union
+    {
+        UINT16 typeC;
+        UINT16 typeD;
+        UINT16 raw[3];
+    };
 };

File CppHeaderParser/test/test_CppHeaderParser.py

View file
 
 
 
-# Bug: 3567854
+# Bug: 3567854 and 3568241
 class Beans_TestCase(unittest.TestCase):
 
     def setUp(self):
     
     def test_anonymous_union_name(self):
         return self.assertEqual(self.cppHeader.classes["Beans"]["properties"]["public"][1]["name"], "")
+    
+    def test_second_anonymous_union_name(self):
+        return self.assertEqual(self.cppHeader.classes["Beans"]["properties"]["public"][3]["name"], "")
 
 if __name__ == '__main__':
     unittest.main()