File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -1864,7 +1864,8 @@ def _parse_function(
1864
1864
self .visitor .on_class_method (state , method )
1865
1865
else :
1866
1866
assert isinstance (state , (ExternBlockState , NamespaceBlockState ))
1867
- if not method .has_body :
1867
+ # only template specializations can be declared without a body here
1868
+ if not method .has_body and not method .template :
1868
1869
raise self ._parse_error (None , expected = "Method body" )
1869
1870
self .visitor .on_method_impl (state , method )
1870
1871
Original file line number Diff line number Diff line change @@ -1987,3 +1987,43 @@ def test_extern_template() -> None:
1987
1987
},
1988
1988
)
1989
1989
)
1990
+
1991
+
1992
+ def test_fwd_declared_method () -> None :
1993
+ content = """
1994
+ // forward declaration for specialized template function
1995
+ template <> Clazz<A>::Clazz();
1996
+ """
1997
+ data = parse_string (content , cleandoc = True )
1998
+
1999
+ assert data == ParsedData (
2000
+ namespace = NamespaceScope (
2001
+ method_impls = [
2002
+ Method (
2003
+ return_type = None ,
2004
+ name = PQName (
2005
+ segments = [
2006
+ NameSpecifier (
2007
+ name = "Clazz" ,
2008
+ specialization = TemplateSpecialization (
2009
+ args = [
2010
+ TemplateArgument (
2011
+ arg = Type (
2012
+ typename = PQName (
2013
+ segments = [NameSpecifier (name = "A" )]
2014
+ )
2015
+ )
2016
+ )
2017
+ ]
2018
+ ),
2019
+ ),
2020
+ NameSpecifier (name = "Clazz" ),
2021
+ ]
2022
+ ),
2023
+ parameters = [],
2024
+ template = TemplateDecl (),
2025
+ constructor = True ,
2026
+ )
2027
+ ]
2028
+ )
2029
+ )
You can’t perform that action at this time.
0 commit comments