Commit Graph

11 Commits

Author SHA1 Message Date
Olly Betts 0b4496a735 Fix testsuite SWIG warnings; enable SWIG -Werror
SWIG/mzscheme (aka racket) is excluded for now as it currently has a lot
of testsuite warnings and is slated for removal in 4.4.0 anyway.

Closes #3034
2024-10-22 10:30:52 +13:00
William S Fulton df22fad547 Work around Visual Studio 2017 bug in testcase 2023-08-08 19:19:19 +01:00
William S Fulton 2e1506c189 Add support for using declarations to introduce templated members
Add support for using declarations to introduce templated member
methods and for inheriting templated constructors, such as:

  struct Base {
    // templated constructor
    template <typename T> Base(const T &t, const char *s) {}
    // templated member method
    template <typename T> void template_method(const T &t, const char *s) {}
  };

  %template(Base) Base::Base<int>;
  %template(template_method) Base::template_method<double>;

  struct Derived : Base {
    using Base::Base;
    using Base::template_method;
  };

Previously the templated methods and constructors were ignored and
not introduced into the Derived class.
2023-08-07 07:37:28 +01:00
William S Fulton 93732bb195 Fix using declarations for deep inheritance hierarchies
Fixes inheritance hierarchies more than two deep and the using
declarations are overloaded. Using declarations
from a base class' base were not available for use in the target
language. For example in the code below, Using1::usingmethod(int i)
was not wrapped for use in Using3:

  struct Using1 {
  protected:
    void usingmethod(int i) {}
  };
  struct Using2 : Using1 {
  protected:
    void usingmethod(int i, int j) {}
    using Using1::usingmethod;
  };
  struct Using3 : Using2 {
    void usingmethod(int i, int j, int k) {}
    using Using2::usingmethod;
  };

Similarly for C++11 using declarations for inheriting constructors.
2023-08-05 19:47:17 +01:00
William S Fulton 525426911c C++11 using declarations for inheriting implicit base templated constructors
Testcase - compiles given previous commit, but needs more work!
2023-07-21 19:28:27 +01:00
William S Fulton 2ff9da0ce6 Constructors and destructors declared with template parameters
Recent commits for internal constructor and destructor names resulted
in destructors declared with template parameters being ignored
with warnings like:
  Illegal destructor name TemplPublicBase6< int >::~TemplPublicBase6(). Ignored.

Although declaring constructors and destructors with template parameters
are rejected by modern compilers and C++20, SWIG continues to support it.

Make sure the name stored in the parse tree is the C++20 compliant name
name, that is, without the template parameters.

Fixes using declarations for templated constructors declared with
template parameters, was warning with:
  Nothing known about 'TemplPublicBase6< int >::TemplPublicBase6'.
2023-07-18 19:29:40 +01:00
William S Fulton 6bcf612c92 C++11 using declarations for inheriting constructors
Support extended to directors.

Go protected constructors fix required for new testcase:
- Emit wrappers if director class is abstract
- If called, errors out with: accessing abstract class or protected constructor
- Now consistent with other target languages
2023-07-15 12:41:12 +01:00
William S Fulton feb8e2e641 Fix C++11 using declarations for inheriting implicit base constructors
Parser no longer checks for a declared constructor when handling a
using declaration in order to correct the name as it won't find
implicitly declared constructors. Now it checks that a using
declaration is for something that looks like a constructor instead
by checking the immediate base classes for allowed constructors.
2023-07-14 08:39:27 +01:00
William S Fulton a0bde3f319 C++11 using declarations for inheriting constructors - template classes with template base classes
Internal using name no longer contains template parameters.
Fixes symbol table lookup for non-instantiated template constructor.
Builds on previous few commits where the internal name no longer
contains the template parameters for constructors and destructors.
2023-07-08 20:01:39 +01:00
William S Fulton 5b9179ea7e C++11 using declarations for template classes with non-template base classes 2023-07-07 12:05:09 +01:00
William S Fulton 22691b76a6 Add missing testcase 2023-07-05 09:39:34 +01:00