Extern template tweaks

Document extern template functions support.
Extern templates result in new warning to differentiate
from template explicit instantiation definition warning.
This commit is contained in:
William S Fulton 2022-01-25 00:28:08 +00:00
commit 017900d57e
8 changed files with 89 additions and 16 deletions

View file

@ -4355,29 +4355,30 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN {
parsing_template_declaration = 0;
}
/* Explicit template instantiation */
/* Class template explicit instantiation definition */
| TEMPLATE cpptype idcolon {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
$$ = 0;
}
/* Explicit function template instantiation */
/* Function template explicit instantiation definition */
| TEMPLATE cpp_alternate_rettype idcolon LPAREN parms RPAREN {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit function template instantiation ignored.\n");
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
$$ = 0;
}
}
/* Explicit class template instantiation without the translation unit */
/* Class template explicit instantiation declaration (extern template) */
| EXTERN TEMPLATE cpptype idcolon {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit (extern) class template instantiation ignored.\n");
Swig_warning(WARN_PARSE_EXTERN_TEMPLATE, cparse_file, cparse_line, "Extern template ignored.\n");
$$ = 0;
}
/* Explicit function template instantiation without the translation unit */
/* Function template explicit instantiation declaration (extern template) */
| EXTERN TEMPLATE cpp_alternate_rettype idcolon LPAREN parms RPAREN {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit (extern) function template instantiation ignored.\n");
Swig_warning(WARN_PARSE_EXTERN_TEMPLATE, cparse_file, cparse_line, "Extern template ignored.\n");
$$ = 0;
}
;
}
;
cpp_template_possible: c_decl {
$$ = $1;

View file

@ -93,6 +93,7 @@
#define WARN_PARSE_NESTED_TEMPLATE 324
#define WARN_PARSE_NAMED_NESTED_CLASS 325
#define WARN_PARSE_EXTEND_NAME 326
#define WARN_PARSE_EXTERN_TEMPLATE 327
#define WARN_CPP11_LAMBDA 340
#define WARN_CPP11_ALIAS_DECLARATION 341 /* redundant now */