Allow `using typename Foo;`

C++11 allows the typename disambiguator to be used outside a template
but SWIG wasn't allowing it in this particular situation.

Fixes #1032
This commit is contained in:
Olly Betts 2023-05-25 14:17:48 +12:00
parent 10dc9bb0ce
commit 1c85c0c135
3 changed files with 19 additions and 1 deletions

View File

@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.0 (in progress)
===========================
2023-05-25: olly
#1032 Allow typename disambiguator in:
using typename NodeT::links_type;
2023-05-25: olly
SWIG now discriminates between long double, double and float
constants. For example, this means that for target languages which

View File

@ -18,7 +18,10 @@ namespace nspace1 {
using nspace1::AffineMatrix;
using nspace1::CacheView;
using nspace1::Abstract;
// Check that `typename` disambiguator parses. Regression test for
// https://github.com/swig/swig/issues/1032 fixed in SWIG 4.2.0.
// Note: `typename` is not needed here, but should be accepted.
using typename nspace1::Abstract;
void _internal(const Abstract *) {}

View File

@ -4498,6 +4498,16 @@ cpp_using_decl : USING idcolon SEMI {
Delete(name);
add_symbols($$);
}
| USING TYPENAME idcolon SEMI {
String *uname = Swig_symbol_type_qualify($3,0);
String *name = Swig_scopename_last($3);
$$ = new_node("using");
Setattr($$,"uname",uname);
Setattr($$,"name", name);
Delete(uname);
Delete(name);
add_symbols($$);
}
| USING NAMESPACE idcolon SEMI {
Node *n = Swig_symbol_clookup($3,0);
if (!n) {