Skip to content

Commit 6d63114

Browse files
rktdmjdrouhard
authored andcommitted
feat: allow extern template instantiantions
Fixes #301
1 parent 413a2e6 commit 6d63114

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

grammar.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,13 @@ module.exports = grammar(C, {
394394
),
395395
),
396396

397-
template_instantiation: $ => seq(
397+
template_instantiation: $ => prec(1, seq(
398+
optional('extern'),
398399
'template',
399400
optional($._declaration_specifiers),
400401
field('declarator', $._declarator),
401402
';',
402-
),
403+
)),
403404

404405
template_parameter_list: $ => seq(
405406
'<',

test/corpus/declarations.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,8 @@ Explicit template instantiations
14311431

14321432
template A<int, bool>::A(char *, size_t);
14331433

1434+
extern template int Foo::foo<int>();
1435+
14341436
--------------------------------------------------------------------------------
14351437

14361438
(translation_unit
@@ -1450,7 +1452,18 @@ template A<int, bool>::A(char *, size_t);
14501452
(primitive_type)
14511453
(abstract_pointer_declarator))
14521454
(parameter_declaration
1453-
(primitive_type))))))
1455+
(primitive_type)))))
1456+
(template_instantiation
1457+
(primitive_type)
1458+
(function_declarator
1459+
(qualified_identifier
1460+
(namespace_identifier)
1461+
(template_function
1462+
(identifier)
1463+
(template_argument_list
1464+
(type_descriptor
1465+
(primitive_type)))))
1466+
(parameter_list))))
14541467

14551468
================================================================================
14561469
Structured binding declarations

0 commit comments

Comments
 (0)