From 42395a177adaa92c4955248d9b96f337e8923bd8 Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Thu, 31 Mar 2016 13:40:02 +0900 Subject: [PATCH] C++, also support 'extern' for functions. Thanks to Victor Zverovich. --- sphinx/domains/cpp.py | 10 +++++----- tests/test_domain_cpp.py | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sphinx/domains/cpp.py b/sphinx/domains/cpp.py index b436745f3..a3bcd2263 100644 --- a/sphinx/domains/cpp.py +++ b/sphinx/domains/cpp.py @@ -90,9 +90,9 @@ from sphinx.util.docfields import Field, GroupedField decl-specifier -> storage-class-specifier -> - ( "static" (only for member_object and function_object) + ( "static" (only for member_object and function_object) + | "extern" (only for member_object and function_object) | "register" - | "extern" (only for member_object) ) thread_local[opt] (only for member_object) (it can also appear before the others) @@ -3076,13 +3076,13 @@ class DefinitionParser(object): if self.skip_word('static'): storage = 'static' continue + if self.skip_word('extern'): + storage = 'extern' + continue if outer == 'member': if self.skip_word('mutable'): storage = 'mutable' continue - if self.skip_word('extern'): - storage = 'extern' - continue if self.skip_word('register'): storage = 'register' continue diff --git a/tests/test_domain_cpp.py b/tests/test_domain_cpp.py index cc0a7fd8a..129b942da 100644 --- a/tests/test_domain_cpp.py +++ b/tests/test_domain_cpp.py @@ -261,6 +261,8 @@ def test_function_definitions(): check("function", "void f(int *const p)", "f__iPC", "1fPCi") check("function", "void f(int *volatile const p)", "f__iPVC", "1fPVCi") + check('function', 'extern int f()', 'f', '1fv') + # TODO: make tests for functions in a template, e.g., Test # such that the id generation for function type types is correct.