Commit Graph

154 Commits

Author SHA1 Message Date
Olly Betts 6c4010e442 Resolve -Wstrict-prototypes warnings with clang-15
warning: a function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]
2022-06-30 12:52:00 +12:00
Olly Betts b2c58115d7 Fix previous commit
Revert changes inadvertently included, and fix `=` to `==`.
2022-03-20 19:44:23 +13:00
Olly Betts 029ddab8b5 [ci] Try to fix failing appveyor python builds 2022-03-20 18:42:50 +13:00
Olly Betts f8a766295c Handle `)` in command line interface filename
SWIG now handles an interface filename specified on the command line
which contains a closing parenthesis `)`, and more generally with
attributes to `%include` and `%import` which are quoted and contain
parentheses.

Fixes #1006
2022-03-08 18:15:18 +13:00
Olly Betts 735732d721 Eliminate calls to abort()
Call Exit(EXIT_FAILURE) instead so that output files get removed.
2022-03-06 14:21:06 +13:00
Olly Betts 74d12d8c4c Don't report "Warning 202: Error: ..."
An invalid preprocessor expression is reported as a pair of
warnings with the second giving a more detailed message from the
expression evaluator.  Previously SWIG prefixed the second message
with "Error:" - that was confusing as it's actually only a warning
by default so we've now dropped this prefix.

Before:

x.i:1: Warning 202: Could not evaluate expression '1.2'
x.i:1: Warning 202: Error: 'Floating point constant in preprocessor expression'

Now:

x.i:1: Warning 202: Could not evaluate expression '1.2'
x.i:1: Warning 202: Floating point constant in preprocessor expression

See #1465
2022-02-24 08:40:27 +13:00
William S Fulton 661cd54526 Fix -Wchar-subscripts warning
warning: array subscript has type ‘char’ [-Wchar-subscripts]
2021-04-26 22:32:52 +01:00
William S Fulton 1f46d9b7b9 Fix regression parsing gcc preprocessor linemarkers
These are preprocessor statement in the form:

 # linenum filename flags

Closes #1475
2019-02-19 21:32:04 +00:00
Luca Longinotti 30719feaf9 Fix handling of // comments inside macro arguments
/* */ are already handled correctly.

This completes the fix from commit
624ec3e1b7 related to swig/swig#974.
2018-03-07 14:49:08 +13:00
William S Fulton 72964a1faf Don't accept some invalid preprocessor code
Whitespace or non-numeric characters are required after a preprocessor
directive that requires an expression.
2018-01-16 08:07:37 +00:00
William S Fulton ab5559f51c Fix out of bounds memory problems in handling simple macro arguments
Fixes handling macro in swigmacros.swg:
  #define %arg(Arg...)        Arg

AddressSanitizer error running Python test-suite.
2018-01-14 13:25:57 +00:00
Olly Betts f85d87a64c Fix bug with macro invocation with empty first arg
The first argument was being dropped in this case.
2017-10-08 09:02:28 +13:00
Olly Betts 866840f791 Fix handling of macro with empty argument list 2017-10-08 09:02:28 +13:00
Philip Herron 624ec3e1b7 Fix bug with comments inline in macros
- commit fixes #974
2017-04-27 15:35:13 +01:00
Olly Betts 7a3cfdb013 Fix GCC 7 warnings
From -Wimplicit-fallthrough which is now enabled by -W.
2016-12-21 13:05:20 +13:00
Olly Betts d26a505dad Ignore unknown preprocessor directives which are inside an inactive
conditional (github issue #394, reported by Dan Wilcox).
Regression introduced in 3.0.3.
2015-04-30 13:40:42 +12:00
Olly Betts be4065531e Add suggestion to check block delimiter
The fix for #217 means that blocks of target code delimited by { } with
'#' comments in now give errors (previously these lines were quietly
discarded).

The fix is generally to use %{ %} delimiters instead, so suggest this
might be the issue in the error message to help users hitting this issue
with wrappers which were apparently working before.
2015-01-14 16:08:08 +13:00
Olly Betts ce90ff6a77 When reporting an error for a construct which hasn't been terminated
when the end of the file is reached, report it at the start line rather
than "EOF" as then tools like editors and IDEs will take you to a
generally more useful place for fixing the problem.
2015-01-08 13:19:17 +13:00
William S Fulton 93d58cd3ed Fix use of preprocessor null directive
This was broken recently in commit 255c929c56
for issue #217
2014-12-20 17:05:13 +00:00
Olly Betts 255c929c56 Issue an error for unknown SWIG preprocessor directives, rather
than quietly ignoring them.  Reported by jrhelsey in issue#217.
2014-09-01 00:26:15 -03:00
William S Fulton 7841a0d097 Remove cvs/svn Id strings 2013-01-12 01:21:16 +00:00
William S Fulton dac89e16d4 const char * correctness fixes (in C code)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13939 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-26 20:30:37 +00:00
William S Fulton b596ddbbc1 Correct type change from char * to String introduced in rev 13904
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13937 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-26 20:28:09 +00:00
William S Fulton d918bddfc0 Fix segfaults when using filename paths greater than 1024 characters in length - use String * and heap instead of fixed size static char array buffers.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13904 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-18 00:45:18 +00:00
William S Fulton 475c6c6ce0 Suppress some unchecked return value warnings for Coverity
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13902 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-18 00:44:19 +00:00
William S Fulton 3d6b068b8c Add some assertions around use of Tell
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13896 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-16 19:38:48 +00:00
William S Fulton e87e94572e Fix unused variables found by Coverity checker
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13892 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-11-16 19:33:43 +00:00
William S Fulton 425b460a09 Fix %include inside %define macros - patch from Karl Wette
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12924 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2012-03-15 20:32:14 +00:00
William S Fulton f5feb6cc24 Fix regression introduced in swig-2.0.2 where filenames with spaces were not found when used with %include and %import
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12546 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-03-17 07:33:05 +00:00
William S Fulton 0913f41fb4 Change preprocessing error for tokens appearing after #else and #end to warning. Add some missing warning documentation and a couple of warning messages tidy up.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12467 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-17 21:54:13 +00:00
William S Fulton efd06d0668 Preprocessing now errors out if extra tokens appear after #else and #end. Add preprocessor errors when preprocessor expressions are missing
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12464 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-16 20:48:48 +00:00
William S Fulton e0ee14c3ba Fix Fix #1927852 - #include directives don't preprocess the file passed to it
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12457 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-13 13:53:14 +00:00
William S Fulton 16ba0aca53 Fix preprocessor breakages introduced in rev 12441 which was fixing defined() being expanded outside of #if and #elif preprocessor directives
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12455 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-12 23:27:50 +00:00
William S Fulton 63af0a2d72 Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif preprocessor directives.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12441 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2011-02-07 07:29:55 +00:00
William S Fulton efb9090a87 Fix correct line number reporting in errors/warnings when a macro definition ends with '/' and it is not the end of a C comment - swig.swg has some of these macro definitions.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12215 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-11 11:02:18 +00:00
William S Fulton f82811dbcd Fix incorrect line number reporting in errors/warnings after parsing macro invocations with parameters given over more than one line.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12214 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-10 23:44:27 +00:00
William S Fulton 122bc852f9 Fix #2149523 - Incorrect line number reporting in errors after parsing macros. Remove extraneous extra line in preprocessed output which would sometimes lead to error/warning messages two lines after the end of the file
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12211 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-10 06:08:45 +00:00
William S Fulton 04c3e6b7d3 Fix line numbering for 'Unterminated call invoking macro' error
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12202 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-06 17:30:18 +00:00
William S Fulton 197c8e899d Fix erroneous line numbers in argument count error messages for macro expansions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12201 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-03 18:44:01 +00:00
William S Fulton a44f83cf05 Fix line numbers in error and warning messages which were accumulately one less than they should have been after parsing each %include/%import - bug introduced in swig-1.3.32. Also fix line numbers in error and warning messages when new line characters appear between the %include / %import statement and the filename.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12199 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-03 06:03:48 +00:00
William S Fulton aa728ece67 Fix __LINE__ and __FILE__ expansion in macros with no arguments
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12197 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-09-01 21:06:10 +00:00
William S Fulton 31b5f36b74 Fix line number and file name reporting for some macro preprocessor warnings.
The line number of the macro argument has been corrected and the line number
of the start of the macro instead of one past the end is used. Some examples:
  file.h:11: Error: Illegal macro argument name '..'
  file.h:19: Error: Macro 'DUPLICATE' redefined,
  file.h:15: Error: previous definition of 'DUPLICATE'.
  file.h:25: Error: Variable-length macro argument must be last parameter
  file.h:32: Error: Illegal character in macro argument name
  file.i:37: Error: Macro 'SIT' expects 2 arguments

Code used for testing:
// file.h
%define SIT(ax,b)
abc(
%enddef

%define MISSING_DOT1(a,
b,
..)
xxx
%enddef

%define MISSING_DOT2(..)
xxx
%enddef

%define DUPLICATE(a,b)
abc
%enddef

%define DUPLICATE(b)
xxx
%enddef

%define VARARGS_WRONG(a,
x,
...,
 b)
xxx
%enddef

%define BAD_ARGNAME(
a,
b{c
)
xxx
%enddef

SIT(1)


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12195 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-08-29 23:32:49 +00:00
William S Fulton 5a6443ebcf Fix some more instances of __LINE__ and __FILE__ numbering
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12194 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-08-29 22:11:03 +00:00
William S Fulton 69af82caa4 Fix __LINE__ and __FILE__ expansion. Mostly this did not work at all.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12192 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-08-26 18:06:02 +00:00
Olly Betts bf1d3f0714 Remove superfluous semicolons.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12034 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-05-21 07:10:12 +00:00
William S Fulton cb64f65bae SWIG license change - Source moves to GPLv3
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11876 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-27 23:53:33 +00:00
William S Fulton 207ba5ce39 Fix #1807329 - When Makefile dependencies are being generated using the -M family of options on Windows, the file paths have been corrected to use single backslashes rather than double backslashes as path separators.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11847 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-02-08 23:12:27 +00:00
William S Fulton 3932d02a2a fix SWIG naming convention
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11663 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-08-21 00:25:11 +00:00
Haoyu Bai 1d1ee5bae7 Fix broken caused by merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11098 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-30 10:32:59 +00:00
Haoyu Bai 47b4825168 Merged revisions 11085-11086,11088-11089 via svnmerge from
https://swig.svn.sourceforge.net/svnroot/swig/branches/swig-2.0

........
  r11085 | bhy | 2009-01-25 00:21:55 +0800 (Sun, 25 Jan 2009) | 2 lines
  
  Fix const-correctness.
........
  r11086 | bhy | 2009-01-25 02:08:50 +0800 (Sun, 25 Jan 2009) | 2 lines
  
  Correct some function definition in header files, which implementation changed in previous commit caused mismatch.
........
  r11088 | bhy | 2009-01-25 02:38:32 +0800 (Sun, 25 Jan 2009) | 1 line
  
  minor fix and now SWIG is alive again
........
  r11089 | bhy | 2009-01-25 06:07:07 +0800 (Sun, 25 Jan 2009) | 1 line
  
  Correct some bug introduced in previous commits. Now SWIG is pretty good with C++ compiler.
........


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11097 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2009-01-30 10:27:37 +00:00