com php-src: Error on multiple default blocks in a switch: Zend/tests/034.phpt Zend/zend_compile.c
| From: | Joe Watkins | Date: | Fri, 05 Sep 2014 22:07:07 +0000 |
| Subject: | com php-src: Error on multiple default blocks in a switch: Zend/tests/034.phpt Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81687@lists.php.net to get a copy of this message | ||
Commit: b476eca8261095f1853764c9a8ac2938a71e85d1
Author: Levi Morrison <levim@php.net> Fri, 5 Sep 2014 16:07:07 -0600
Parents: 7d0416f4018103f95c4f06daabe60769310ffa6e
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b476eca8261095f1853764c9a8ac2938a71e85d1
Log:
Error on multiple default blocks in a switch
Part of RFC: https://wiki.php.net/rfc/switch.default.multiple
Changed paths:
M Zend/tests/034.phpt
M Zend/zend_compile.c
Diff:
diff --git a/Zend/tests/034.phpt b/Zend/tests/034.phpt
index 6e46f26..0bcfa23 100644
--- a/Zend/tests/034.phpt
+++ b/Zend/tests/034.phpt
@@ -22,5 +22,5 @@ switch (1) {
}
?>
---EXPECT--
-3
+--EXPECTF--
+Fatal error: Switch statements may only contain one default clause in %s on line 13
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index a5a3229..3af97cc 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5091,6 +5091,11 @@ void zend_compile_switch(zend_ast *ast TSRMLS_DC) /* {{{ */
znode cond_node;
if (!cond_ast) {
+ if (has_default_case) {
+ CG(zend_lineno) = case_ast->lineno;
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "Switch statements may only contain one default clause");
+ }
has_default_case = 1;
continue;
}