Allow arbitrary const expressions in backed enums

Closes GH-7821
Closes GH-8190
Closes GH-8418
This commit is contained in:
Ilija Tovilo 2022-03-10 22:35:01 +01:00
parent 5a855ee8d6
commit ddc0b490f7
No known key found for this signature in database
GPG key ID: A4F5D403F118200A
23 changed files with 287 additions and 144 deletions

View file

@ -30,6 +30,7 @@
#include "zend_closures.h"
#include "zend_inheritance.h"
#include "zend_ini.h"
#include "zend_enum.h"
#include <stdarg.h>
@ -1493,6 +1494,12 @@ ZEND_API zend_result zend_update_class_constants(zend_class_entry *class_type) /
}
}
if (class_type->type == ZEND_USER_CLASS && class_type->ce_flags & ZEND_ACC_ENUM && class_type->enum_backing_type != IS_UNDEF) {
if (zend_enum_build_backed_enum_table(class_type) == FAILURE) {
return FAILURE;
}
}
ce_flags |= ZEND_ACC_CONSTANTS_UPDATED;
ce_flags &= ~ZEND_ACC_HAS_AST_CONSTANTS;
ce_flags &= ~ZEND_ACC_HAS_AST_PROPERTIES;