diff --git a/CHANGES.current b/CHANGES.current index 9e6a04cc3..2cf0bc497 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2020-10-10: wsfulton + #252 complex can now be used as a C identifier and doesn't give a syntax error. + 2020-10-10: lpsinger #1770 Correct C complex support. _Complex is now parsed as a keyword rather than complex as per the C99 standard. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 55cbd2cce..bddae4b2f 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -718,6 +718,7 @@ C_TEST_CASES += \ nested_extend_c \ nested_structs \ newobject2 \ + not_ckeywords \ overload_extend_c \ overload_extend2 \ preproc \ diff --git a/Examples/test-suite/not_c_keywords.i b/Examples/test-suite/not_c_keywords.i new file mode 100644 index 000000000..013575bc6 --- /dev/null +++ b/Examples/test-suite/not_c_keywords.i @@ -0,0 +1,13 @@ +%module not_c_keywords + +%extend ComplexStruct { +void init() { + $self->complex = 123; +} +} + +%inline %{ +struct ComplexStruct { + int complex; /* complex as variable name */ +}; +%} diff --git a/Examples/test-suite/python/not_c_keywords_runme.py b/Examples/test-suite/python/not_c_keywords_runme.py new file mode 100644 index 000000000..7f0772407 --- /dev/null +++ b/Examples/test-suite/python/not_c_keywords_runme.py @@ -0,0 +1,7 @@ +from not_c_keywords import * + +cs = ComplexStruct() +cs.init() +if cs.complex != 123: + raise RuntimeError("complex not correct") +cs.complex = 456 diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 66518f50c..fbf02bb1f 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -134,7 +134,7 @@ SwigType *NewSwigType(int t) { return NewString("double"); break; case T_COMPLEX: - return NewString("complex"); + return NewString("_Complex"); break; case T_CHAR: return NewString("char");