From 85c69ffc5de0fce0e2a9413a074de4a5f17af1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Sat, 13 Jul 2013 11:22:43 +0200 Subject: [PATCH] Compiler: Fixed over optimization in __INIT(). Constant expressions that have external dependencies that evaluate to zero should not be removed, since they may get overloaded later. Also fixes forward refering constants like in the Calendar module: program Foo = cFoo; class cFoo { // ... } Fixes [LysLysKOM 20361227]/Pike mailinglist 13656. Thanks to Chris Angelico <rosuav@gmail.com> for the report. --- src/language.yacc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/language.yacc b/src/language.yacc index d27aee0333..b111afd95a 100644 --- a/src/language.yacc +++ b/src/language.yacc @@ -1707,7 +1707,9 @@ new_name: optional_stars TOK_IDENTIFIER } expr0 { - if (!TEST_COMPAT(7, 8) && is_const($5) && !Pike_compiler->num_parse_error) { + if (!TEST_COMPAT(7, 8) && ($5) && is_const($5) && + !($5->tree_info & OPT_EXTERNAL_DEPEND) && + !Pike_compiler->num_parse_error) { /* Attempt to evaluate it to see if it is zero, * in which case we can throw it away. * -- GitLab