Commit graph

23,273 commits

Author SHA1 Message Date
William S Fulton
004af63f3c Syntax error fixes parsing more elaborate parameter pack arguments
that are function pointers and member function pointers.

  template <typename... V> struct VariadicParms {
    void ParmsFuncPtrPtr(int (*)(V*...)) {}
    void ParmsFuncPtrPtrRef(int (*)(V*&...)) {}
    void ParmsFuncPtrPtrRValueRef(int (*)(V*&&...)) {}
    void ParmsFuncPtrRef(int (*)(V&...)) {}
    void ParmsFuncPtrRValueRef(int (*)(V&&...)) {}

    void ParmsMemFuncPtrPtr(int (KlassMemFuncs::*)(V*...)) {}
    void ParmsMemFuncPtrPtrRef(int (KlassMemFuncs::*)(V*&...)) {}
    void ParmsMemFuncPtrPtrRValueRef(int (KlassMemFuncs::*)(V*&&...)) {}
    void ParmsMemFuncPtrRef(int (KlassMemFuncs::*)(V&...)) {}
    void ParmsMemFuncPtrRValueRef(int (KlassMemFuncs::*)(V&&...)) {}
  };

  %template(VariadicParms0) VariadicParms<>;
  %template(VariadicParms1) VariadicParms<A>;

  Also in various other places such as within noexcept specifiers:

    template<typename T, typename... Args>
    void emplace(Args &&... args) noexcept(
        std::is_nothrow_constructible<T, Args &&...>::value);

Issue #1863
2022-12-30 00:19:02 +00:00
William S Fulton
674abaddbf Fix instantiation of variadic class templates
containing parameter pack arguments that are function pointers.

  template <typename... V> struct VariadicParms {
    void ParmsFuncPtrVal(int (*)(V...)) {}
  };

  %template(VariadicParms0) VariadicParms<>;
  %template(VariadicParms1) VariadicParms<A>;
2022-12-29 23:38:17 +00:00
William S Fulton
70837bbc26 Fix syntax error parsing variadic template parameter pack arguments
that are function pointers

Issue #1863
2022-12-23 16:25:50 +00:00
William S Fulton
b13f584258 Lua variadic templates sizeof... constants fix 2022-12-22 22:07:45 +00:00
William S Fulton
91af6cba27 Parser code refactor around variadic types 2022-12-22 21:23:44 +00:00
William S Fulton
cdf9a18603 Document improved variadic template support 2022-12-22 21:23:44 +00:00
William S Fulton
f648e58cb1 Extend variadic template support to various type combinations 2022-12-22 21:23:44 +00:00
William S Fulton
67c4c2186c Support multiple arguments in variadic templates.
Remove warning SWIGWARN_CPP11_VARIADIC_TEMPLATE which was issued if more
than one argument was used for a variadic template.

SwigType enhancement: 'v.' now represents a variadic argument.
2022-12-22 21:23:39 +00:00
William S Fulton
1e73045da8 Refactor Swig_cparse_template_parms_expand()
Break up functionality in Swig_cparse_template_parms_expand() to make it
more readable / maintainable.
2022-12-21 20:15:47 +00:00
William S Fulton
9e8a0daf9e Refactor %template parameters handling
Move code from %template parsing in parser.y into new function
Swig_cparse_template_parms_expand
2022-12-09 19:23:57 +00:00
William S Fulton
8a24c19d26 Fix syntax error for misplaced Doxygen comment after struct/class member.
Fix syntax error using Doxygen member groups syntax, "///*}", when used after
final struct/class member.

Issue #1636
2022-12-06 21:31:38 +00:00
William S Fulton
dc04564023 Improved handling of Doxygen comments in parameter lists
Fix garbled Doxygen post comments in parameter lists.
Fix syntax error parsing a trailing Doxygen comment in parameter lists.

Closes #2023
2022-12-05 19:47:59 +00:00
William S Fulton
f7b4127310 Fix syntax error parsing of Doxygen comments after last enum item
It is unconventional to have a doxygen comment after an enum item. It is
attached to the previous, that is, the enum item to match Doxygen behaviour.

Closes #1609
2022-12-03 10:09:37 +00:00
William S Fulton
24f75aa481 Fix parsing of unconventional Doxygen post comments for enum items.
Closes #1715
2022-12-03 09:49:42 +00:00
William S Fulton
1cdeb458de Testcase fix for -Wdelete-non-virtual-dtor 2022-12-02 22:47:14 +00:00
William S Fulton
8047d5a332 swig-4.1.1 changes
Copy CHANGES.current from release-4.1.1 branch into CHANGES.
Remove items released in 4.1.1 from master CHANGES.current.
2022-12-02 20:57:54 +00:00
William S Fulton
7bdc708e5f Template parameters handling tidy up
Technical correction on how template parameters are stored in a Parm*.
Doesn't actually make any change, but they are now displayed correctly
when using debug options such as -debug-module.
2022-12-02 19:44:59 +00:00
William S Fulton
05b93b1f06 Improved template template parameters support.
Previously, specifying more than one simple template template parameter
resulted in a parse error. Now multiple template template parameters are
working including instantiation with %template. Example:

  template <template<template<class> class, class> class Op, template<class> class X, class Y>
    class C { ... };

Closes #624
Closes #1021
2022-12-02 19:16:02 +00:00
William S Fulton
c85e7f1625 Add ccache-swig hash fix to RELEASENOTES 2022-11-30 07:34:19 +00:00
William S Fulton
95951cb4db Merge branch 'fixes/push-pop-mismatch'
* fixes/push-pop-mismatch:
  Fix push/pop mismatch
2022-11-29 08:09:14 +00:00
William S Fulton
c5e02bf327 Ocaml name mangling fix
Fixes testcase template_expr which was resulting in OCaml syntax errors.
2022-11-29 08:04:37 +00:00
Bernhard Rosenkränzer
8ece583aa0 Fix push/pop mismatch
Without this, perlhead.swg does `#pragma GCC diagnostic pop`
if `__GNUC__ >= 10` - without any prior `#pragma GCC diagnostic push`.

There's also a mismatch between the conditions that trigger
`#pragma GCC diagnostic ignored` (where the `push` should be)
and the attempt to `#pragma GCC diagnostic pop`.
2022-11-29 00:55:07 +01:00
William S Fulton
acf040c3fe Add SWIG-4.1.1 RELEASENOTES summary 2022-11-28 08:02:37 +00:00
William S Fulton
60af317956 Fix UBSAN errors in ccache-swig
ccache.c:738:18: runtime error: null pointer passed as argument 1, which is declared to never be null
Fixes stderr redirect in testname CCACHE_CPP2, when the CCACHE_CPP2
environment variable is defined.

mdfour.c:91:20: runtime error: left shift of 139 by 24 places cannot be represented in type 'int'
Looks like this brings some stability to the md4 hash calculation.

Closes #2449
2022-11-26 18:18:55 +00:00
William S Fulton
637e297672 Test case fix for std::complex and non-floating types deprecation
From Visual Studio 2022:

warning C4996: 'std::complex<int>::complex': warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning.
2022-11-26 10:18:11 +00:00
William S Fulton
ecf05445b9 Test cases fix 2022-11-26 10:04:35 +00:00
William S Fulton
15692f0e89 Add missing testcase cpp11_template_parameters_decltype 2022-11-26 01:27:04 +00:00
William S Fulton
2a1711e436 Slightly better decltype() support for expressions
decltype now accepts C++ expressions instead of just an ID, such as:

  int i,j;
  ...  decltype(i+j) ...
  ...  decltype(&i) ...

These result in a warning for non-trivial expressions which SWIG cannot evaluate:

  Warning 344: Unable to deduce decltype for 'i+j'.

See 'Type Inference' in CPlusPlus.html for workarounds.

Issue #1589
Issue #1590
2022-11-26 01:16:20 +00:00
William S Fulton
9b91b24d6b Fix syntax error parsing unnamed template parameters with a default.
Closes #961
2022-11-25 08:37:39 +00:00
Olly Betts
081d44d45e Follow-on fix for previous change
These cases don't trigger ubsan warnings and seem to work locally
for me, but CI was failing on a number of builds.

See #2447
2022-11-25 12:29:52 +13:00
Olly Betts
81c6a63898 Fix undefined behaviour in parser
Fix undefined behaviour in swig's parser when handling default parameter
expressions containing method calls.

Fixes #2447
2022-11-25 09:51:58 +13:00
William S Fulton
5a8d58c3a7 Merge branch 'rtests2'
* rtests2:
  more r tests
  more r tests
  added testcase pointer_reference
  [PHP] Update docs for removal of -noproxy in SWIG 4.1.0

Conflicts:
	CHANGES.current
2022-11-23 21:12:07 +00:00
William S Fulton
eef3de6574 Variadic template docs correction 2022-11-23 20:39:24 +00:00
William S Fulton
d3095144e1 Optimise SwigType_base implementation
Also fixes assumption that templates start '<' instead of '<('.
Checked java and python test-suite - no changes in output.
2022-11-23 20:22:40 +00:00
William S Fulton
e0904f44eb Restore testing template_expr testcase
Problems handling < and > in template parameters are now fixed.
Remove illegal C++ code (template typedefs) - replace with a function
using same template.
2022-11-23 07:32:12 +00:00
William S Fulton
ca5c68e544 Fix seg fault handling template parameter expressions containing '>='
Similar to previous commit

Issue #1037
2022-11-22 21:40:38 +00:00
William S Fulton
0341258af7 Fix seg fault handling template parameter expressions containing '<='
Recent commits ensure types are correctly stored in SwigType *. In
particular template parameters are enclosed within '<(' and ')>'.
Now we can confidently handle template parameters as really being
delimited as such to fix an infinite loop handling template expressions
containing '<' or '>'. The previous implementation only assumed
template parameters were delimited by '<' and '>'.

Issue #1037
2022-11-22 08:37:35 +00:00
AndLLA
1dd31446ce more r tests 2022-11-20 18:52:00 +01:00
William S Fulton
29bc7492a2 SwigType * handling corrections - Python builtin mangling
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Swig_string_mangle() takes a generic String *, but it was calling
functions that require SwigType *. Swig_string_mangle_type() is
now provided for SwigType *.

The previous commit is a pre-requisite in order to prevent duplicate
symbols from being generated in the C++ wrappers.
2022-11-18 19:44:00 +00:00
William S Fulton
4729cf2b1f Duplicate class template instantiations via %template changes
Named duplicate class template instantiations now issue a warning and are ignored.
Duplicate empty class template instantiations are quietly ignored.

The test cases are fixed for this new behaviour.

This commit is a pre-requisite for the near future so that the Python
builtin wrappers can correctly use the SwigType_namestr function without
generating duplicate symbol names.
2022-11-18 19:35:47 +00:00
AndLLA
a88995a11d more r tests 2022-11-16 22:17:25 +01:00
AndLLA
aab9c9843c Merge branch 'master' into rtests2 2022-11-16 20:57:03 +01:00
AndLLA
63821f1bb5 added testcase pointer_reference 2022-11-16 20:54:45 +01:00
Olly Betts
f1f77c218f [PHP] Update docs for removal of -noproxy in SWIG 4.1.0
Closes #2419
2022-11-13 15:23:42 +13:00
William S Fulton
777fd2c280 Minor refactor of D, C#, Java director code
for overloaded methods. Fixes regression (crash) in director_ignore D
testcase since string mangling names change.
2022-11-12 16:30:25 +00:00
William S Fulton
e3ccabbd4d Simpler names when using SwigType_manglestr for templates
The default template name is generated instead of one with the default
template parameter.

Used in various places such as the type system.
2022-11-12 11:46:52 +00:00
William S Fulton
46f2778412 Consolidate name mangling functions
Swig_string_mangle      => Swig_name_mangle_string
Swig_name_mangle        => Swig_name_mangle_string
Swig_string_mangle_type => Swig_name_mangle_type
2022-11-12 09:18:19 +00:00
William S Fulton
3364c18d06 Remove unused code in mzscheme.cxx 2022-11-12 09:06:26 +00:00
William S Fulton
6a9be797e1 SwigType * handling corrections - mangling
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Swig_string_mangle() takes a generic String *, but it was calling
functions that require SwigType *. Swig_string_mangle_type() is
now provided for SwigType *r. The special template handling
on types now occurs in this function.
2022-11-12 06:42:36 +00:00
William S Fulton
2acdfd77e9 SwigType * handling corrections
Further corrections to pass SwigType * to methods expecting types
instead of passing readable type strings.

Required reworking code that adds a fake inheritance for smart pointers
using the smartptr feature. Swig_smartptr_upcast() added as a support
function for this.
2022-11-09 22:11:27 +00:00