From b1388bcbf927f666d7795592fbb151d929305802 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 5 Jan 2023 16:54:16 +1300 Subject: Parse storage class more flexibly Previously we had a hard-coded list of allowed combinations in the grammar, but this suffers from combinatorial explosion, and results in a vague `Syntax error in input` error for invalid (and missing) combinations. This means we now support a number of cases which are valid C++ but weren't supported. Fixes #302 Fixes #2079 (friend constexpr) Fixes #2474 (virtual explicit) --- Examples/test-suite/cpp11_constexpr.i | 3 +++ Examples/test-suite/cpp11_noexcept.i | 6 ++++++ 2 files changed, 9 insertions(+) (limited to 'Examples') diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i index 5ba9ff243..d830d984a 100644 --- a/Examples/test-suite/cpp11_constexpr.i +++ b/Examples/test-suite/cpp11_constexpr.i @@ -39,6 +39,9 @@ struct ConstExpressions { // Regression tests for https://github.com/swig/swig/issues/284 : explicit constexpr ConstExpressions(int) { } constexpr explicit ConstExpressions(double) { } + // Regression tests for https://github.com/swig/swig/issues/2079 : + constexpr friend bool operator==(ConstExpressions,ConstExpressions) { return true; } + friend constexpr bool operator!=(ConstExpressions,ConstExpressions) { return false; } }; %} diff --git a/Examples/test-suite/cpp11_noexcept.i b/Examples/test-suite/cpp11_noexcept.i index 8aa0baa5a..6b0584473 100644 --- a/Examples/test-suite/cpp11_noexcept.i +++ b/Examples/test-suite/cpp11_noexcept.i @@ -1,5 +1,7 @@ %module cpp11_noexcept +%ignore NoExceptAbstract::operator std::string; +%ignore NoExceptAbstract::operator int; %ignore NoExceptClass(NoExceptClass&&); %rename(Assignment) NoExceptClass::operator=; @@ -7,6 +9,7 @@ extern "C" void global_noexcept(int, bool) noexcept {} %} %inline %{ +#include extern "C" void global_noexcept(int, bool) noexcept; extern "C" void global_noexcept2(int, bool) noexcept {} @@ -43,6 +46,9 @@ struct NoExceptClass { struct NoExceptAbstract { virtual void noo4() const noexcept = 0; virtual ~NoExceptAbstract() noexcept = 0; + // Regression test for https://github.com/swig/swig/issues/2474 + virtual explicit operator std::string() const noexcept = 0; + explicit virtual operator int() const noexcept = 0; }; struct NoExceptDefaultDelete { -- cgit v1.2.1