[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:
Olly Betts 2019-02-08 18:09:52 +13:00
commit 3f9ebb31b9
4 changed files with 26 additions and 1 deletions

View file

@ -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) {
}

View file

@ -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();
?>