mirror of https://github.com/swig/swig
Warn and ignore %constant with unsupported implicit type
SWIG 4.2.0 reported an assertion failure. SWIG 4.1.1 generated C/C++ code which failed to compile.
This commit is contained in:
parent
411e317554
commit
ceafa131de
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.2.1 (in progress)
|
||||
===========================
|
||||
|
||||
2024-02-14: olly
|
||||
SWIG now warns and ignores if %constant is used with an implicit
|
||||
type which SWIG can't deduce.
|
||||
|
||||
2024-02-13: olly
|
||||
Fix type deduction for certain cases involving C-style casts, or
|
||||
which are syntactically like a C-style cast applied to an unary
|
||||
|
|
|
@ -394,6 +394,7 @@ example.i(4) : Syntax error in input(1).
|
|||
<li>301. <tt>class</tt> keyword used, but not in C++ mode.
|
||||
<li>302. Redefinition of identifier '<em>name</em>' as <em>decl</em> ignored.
|
||||
<li>303. <tt>%extend</tt> defined for an undeclared class '<em>name</em>'.
|
||||
<li>304. Unsupported constant value (ignored).
|
||||
<li>305. Bad constant value (ignored).
|
||||
<li>308. Namespace alias '<em>name</em>' not allowed here. Assuming '<em>name</em>'
|
||||
<li>309. [private | protected] inheritance ignored.
|
||||
|
|
|
@ -52,3 +52,13 @@ Type1 getType1Instance() { return Type1(111); }
|
|||
/* Regular constant */
|
||||
%constant int TYPE_INT = 0;
|
||||
%constant enum EnumType newValue = enumValue;
|
||||
|
||||
/* Test handling of %constant with an implicit type which SWIG can't handle. */
|
||||
#pragma SWIG nowarn=SWIGWARN_PARSE_UNSUPPORTED_VALUE
|
||||
%ignore ignored_int_variable;
|
||||
%inline %{
|
||||
int ignored_int_variable = 42;
|
||||
%}
|
||||
%constant unsupported_constant_value1 = &ignored_int_variable;
|
||||
%constant unsupported_constant_value2 = getType1Instance;
|
||||
%constant unsupported_constant_value3 = &getType1Instance;
|
||||
|
|
|
@ -2045,15 +2045,20 @@ clear_directive : CLEAR tm_list SEMI {
|
|||
|
||||
constant_directive : CONSTANT identifier EQUAL definetype SEMI {
|
||||
SwigType *type = NewSwigType($4.type);
|
||||
$$ = new_node("constant");
|
||||
Setattr($$, "name", $2);
|
||||
Setattr($$, "type", type);
|
||||
Setattr($$, "value", $4.val);
|
||||
if ($4.rawval) Setattr($$, "rawval", $4.rawval);
|
||||
Setattr($$, "storage", "%constant");
|
||||
SetFlag($$, "feature:immutable");
|
||||
add_symbols($$);
|
||||
Delete(type);
|
||||
if (Len(type) > 0) {
|
||||
$$ = new_node("constant");
|
||||
Setattr($$, "name", $2);
|
||||
Setattr($$, "type", type);
|
||||
Setattr($$, "value", $4.val);
|
||||
if ($4.rawval) Setattr($$, "rawval", $4.rawval);
|
||||
Setattr($$, "storage", "%constant");
|
||||
SetFlag($$, "feature:immutable");
|
||||
add_symbols($$);
|
||||
Delete(type);
|
||||
} else {
|
||||
Swig_warning(WARN_PARSE_UNSUPPORTED_VALUE, cparse_file, cparse_line, "Unsupported constant value (ignored)\n");
|
||||
$$ = 0;
|
||||
}
|
||||
}
|
||||
| CONSTANT type declarator def_args SEMI {
|
||||
SwigType_push($2, $3.type);
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
#define WARN_PARSE_CLASS_KEYWORD 301
|
||||
#define WARN_PARSE_REDEFINED 302
|
||||
#define WARN_PARSE_EXTEND_UNDEF 303
|
||||
/* Unused since 4.2.0: #define WARN_PARSE_UNSUPPORTED_VALUE 304 */
|
||||
#define WARN_PARSE_UNSUPPORTED_VALUE 304
|
||||
#define WARN_PARSE_BAD_VALUE 305
|
||||
/* Unused since 1.3.32: #define WARN_PARSE_PRIVATE 306 */
|
||||
/* Unused since 4.2.0: #define WARN_PARSE_BAD_DEFAULT 307 */
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
* The warning filter is a string of numbers prefaced by (-) or (+) to
|
||||
* indicate whether or not a warning message is displayed. For example:
|
||||
*
|
||||
* "-301-201-140+210+201"
|
||||
* "-304-201-140+210+201"
|
||||
*
|
||||
* The filter string is scanned left to right and the first occurrence
|
||||
* of a warning number is used to determine printing behavior.
|
||||
|
|
Loading…
Reference in New Issue