summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sphinx/domains/cpp.py25
-rw-r--r--tests/test_cpp_domain.py4
2 files changed, 19 insertions, 10 deletions
diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py
index 77ec032d9..f99c3ffc7 100644
--- a/sphinx/domains/cpp.py
+++ b/sphinx/domains/cpp.py
@@ -425,27 +425,31 @@ class MemberObjDefExpr(NamedDefExpr):
class FuncDefExpr(NamedDefExpr):
- def __init__(self, name, visibility, static, explicit, rv,
+ def __init__(self, name, visibility, static, explicit, constexpr, rv,
signature, const, pure_virtual):
NamedDefExpr.__init__(self, name, visibility, static)
self.rv = rv
self.signature = signature
self.explicit = explicit
+ self.constexpr = constexpr
self.const = const
self.pure_virtual = pure_virtual
def get_id(self):
- return u'%s%s%s' % (
+ return u'%s%s%s%s' % (
self.name.get_id(),
self.signature and u'__' +
u'.'.join(x.get_id() for x in self.signature) or u'',
- self.const and u'C' or u''
+ self.const and u'C' or u'',
+ self.constexpr and 'CE' or ''
)
def __unicode__(self):
buf = self.get_modifiers()
if self.explicit:
buf.append(u'explicit')
+ if self.constexpr:
+ buf.append(u'constexpr')
if self.rv is not None:
buf.append(unicode(self.rv))
buf.append(u'%s(%s)' % (self.name, u', '.join(
@@ -815,11 +819,14 @@ class DefinitionParser(object):
def parse_function(self):
visibility, static = self._parse_visibility_static()
- if self.skip_word('explicit'):
- explicit = True
- self.skip_ws()
- else:
- explicit = False
+ def _read_word(x):
+ if self.skip_word(x):
+ self.skip_ws()
+ return True
+ return False
+ explicit = _read_word('explicit')
+ constexpr = _read_word('constexpr')
+
rv = self._parse_type()
self.skip_ws()
# some things just don't have return values
@@ -828,7 +835,7 @@ class DefinitionParser(object):
rv = None
else:
name = self._parse_type()
- return FuncDefExpr(name, visibility, static, explicit, rv,
+ return FuncDefExpr(name, visibility, static, explicit, constexpr, rv,
*self._parse_signature())
def parse_class(self):
diff --git a/tests/test_cpp_domain.py b/tests/test_cpp_domain.py
index eb08c6085..a4e805100 100644
--- a/tests/test_cpp_domain.py
+++ b/tests/test_cpp_domain.py
@@ -48,10 +48,12 @@ def test_type_definitions():
assert unicode(parse('type_object', 'long long int foo')) == 'long long foo'
-
x = 'MyClass::MyClass(MyClass::MyClass&&)'
assert unicode(parse('function', x)) == x
+ x = 'constexpr int get_value()'
+ assert unicode(parse('function', x)) == x
+
def test_operators():
x = parse('function', 'void operator new [ ] ()')