Commits

Takayuki Shimizukawa committed efd13f9

fix: cpp domain parser cannot parse a const type with a modifier. closes #1041

  • Participants
  • Parent commits dfccd80
  • Branches #1041

Comments (0)

Files changed (2)

File sphinx/domains/cpp.py

         except ValueError:
             return False
 
-    def _parse_builtin(self, modifier):
-        path = [modifier]
+    def _parse_builtin(self, modifiers):
+        modifier = modifiers[-1]
+        path = modifiers
         following = self._modifiers[modifier]
         while 1:
             self.skip_ws()
                     # impossible for a template to follow, so what
                     # we do is go to a different function that just
                     # eats types
+                    modifiers.append(modifier)
                     if following is not None:
-                        return self._parse_builtin(modifier)
-                    modifiers.append(modifier)
+                        return self._parse_builtin(modifiers)
+                    self.skip_ws()
                 else:
                     self.backout()
                     break

File tests/test_cpp_domain.py

     x = 'int printf(const char* fmt, ...)'
     assert unicode(parse('function', x)) == x
 
+    x = 'int foo(const unsigned int j)'
+    assert unicode(parse('function', x)) == x
+
+    x = 'int foo(const unsigned int const j)'
+    assert unicode(parse('function', x)) == x
+
+    x = 'int foo(const int* const ptr)'
+    assert unicode(parse('function', x)) == x
+
     x = 'std::vector<std::pair<std::string, long long>> module::blah'
     assert unicode(parse('type_object', x)) == x