[PHP] Don't generate code referencing undefined $r
This could happen in overloaded methods which returned void and took at least one const std::string& parameter.
This commit is contained in:
parent
7345a33ccf
commit
3f9ebb31b9
4 changed files with 26 additions and 1 deletions
|
|
@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.0.0 (in progress)
|
||||
===========================
|
||||
|
||||
2019-02-08: olly
|
||||
[PHP] Don't generate code which references $r when $r hasn't been
|
||||
defined. This could happen in overloaded methods which returned
|
||||
void and took at least one const std::string& parameter.
|
||||
|
||||
2019-02-08: olly
|
||||
[PHP] The generated code is now compatible with PHP 7.3, and the
|
||||
testsuite now runs cleanly with this version too.
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ const std::string& test_const_reference(const std::string &x) {
|
|||
return x;
|
||||
}
|
||||
|
||||
void test_const_reference_returning_void(const std::string &) {
|
||||
}
|
||||
|
||||
void test_const_reference_returning_void(const std::string &, int) {
|
||||
}
|
||||
|
||||
void test_pointer(std::string *x) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,17 @@
|
|||
require "tests.php";
|
||||
require "li_std_string.php";
|
||||
|
||||
function die_on_error($errno, $errstr, $file, $line) {
|
||||
if ($file !== Null) {
|
||||
print $file;
|
||||
if ($line !== Null) print ":$line";
|
||||
print ": ";
|
||||
}
|
||||
print "$errstr\n";
|
||||
exit(1);
|
||||
}
|
||||
set_error_handler("die_on_error", -1);
|
||||
|
||||
// Global variables
|
||||
//$s="initial string";
|
||||
//check::equal(GlobalString2_get() ,"global string 2", "GlobalString2 test 1");
|
||||
|
|
@ -27,5 +38,8 @@ check::equal(Structure::StaticMemberString2(), $s, "StaticMemberString2 test 2")
|
|||
// below broken ?
|
||||
//check::equal(Structure::ConstStaticMemberString(), "const static member string", "ConstStaticMemberString test");
|
||||
|
||||
// This used to give "Undefined variable: r"
|
||||
li_std_string::test_const_reference_returning_void("foo");
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ public:
|
|||
/* Insert argument output code */
|
||||
bool hasargout = false;
|
||||
for (i = 0, p = l; p; i++) {
|
||||
if ((tm = Getattr(p, "tmap:argout"))) {
|
||||
if ((tm = Getattr(p, "tmap:argout")) && Len(tm)) {
|
||||
hasargout = true;
|
||||
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||
// Replaceall(tm,"$input",Getattr(p,"lname"));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue