From 5a2656ab8077b92bcaf3d21f0b61966aa6594797 Mon Sep 17 00:00:00 2001 From: Seth R Johnson Date: Fri, 4 Feb 2022 13:57:08 -0500 Subject: [PATCH] Don't mark as "noassign" when a variable is immutable I had assumed member variables could only be noassign by being "const", but I had forgotten about the `%immutable` keyword being applied via SWIG. --- Examples/test-suite/cpp_basic.i | 6 ++++++ Source/Modules/allocate.cxx | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/cpp_basic.i b/Examples/test-suite/cpp_basic.i index 365873eda..854664030 100644 --- a/Examples/test-suite/cpp_basic.i +++ b/Examples/test-suite/cpp_basic.i @@ -80,6 +80,12 @@ private: */ }; +// This class is valid C++ but cannot be assigned to. +struct JustConstMemberData { +explicit JustConstMemberData(int i_inp) : i(i_inp) {} +const int i; +}; + %} %{ diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index 56b6f0b08..7d567395c 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -781,10 +781,7 @@ Allocate(): Setattr(n, "cplus:staticbase", inclass); } else if (Cmp(Getattr(n, "kind"), "variable") == 0) { /* Check member variable to determine whether assignment is valid */ - if (GetFlag(n, "feature:immutable")) { - /* Can't assign a class with an immutable member variable */ - Setattr(inclass, "allocate:noassign", "1"); - } else if (SwigType_isreference(Getattr(n, "type"))) { + if (SwigType_isreference(Getattr(n, "type"))) { /* Can't assign a class with reference member data */ Setattr(inclass, "allocate:noassign", "1"); }