April 15, 2011 [dmd-internals] [D-Programming-Language/dmd] cde2fd: 3779 ["123"][0][$-1] causes __dollar unresolved in... | ||||
---|---|---|---|---|
| ||||
Branch: refs/heads/master Home: https://github.com/D-Programming-Language/dmd Commit: cde2fd175ddd270a017778395afed3f7d0a3c2f1 https://github.com/D-Programming-Language/dmd/commit/cde2fd175ddd270a017778395afed3f7d0a3c2f1 Author: Don Clugston <dclugston at googlemail.com> Date: 2011-04-14 (Thu, 14 Apr 2011) Changed paths: M src/optimize.c Log Message: ----------- 3779 ["123"][0][$-1] causes __dollar unresolved in compile-time. After constant folding the array, we should see if we now know __dollar. Commit: fc67046cf1e66182d959309fb15ef9e2d4c266b9 https://github.com/D-Programming-Language/dmd/commit/fc67046cf1e66182d959309fb15ef9e2d4c266b9 Author: Don Clugston <dclugston at googlemail.com> Date: 2011-04-14 (Thu, 14 Apr 2011) Changed paths: M src/dsymbol.c M src/mtype.c M src/optimize.c M src/statement.c M src/template.c Log Message: ----------- Ensure compile-time constants are not variables(!) This fixes a serious structural problem: if a runtime variable is used where a compile-time constant is required, it will most likely still compile. But the code will be wrong. The root cause for this is an inconsistency in the meaning of optimize(WANTinterpret). It has two meanings: (A) In the CTFE engine, and throughout most of the compiler, WANTinterpret is used when an actual compile-time value is required. (B) But in a few places, it just means that it's permissible (but not mandatory) to use CTFE. This actually doesn't make sense -- if it hits a call statement, it WILL interpret, and if that fails, it will generate an error message. The silent errors happen in optimize.c, fromConstInitializer(). I've changed it to give an error message when the variable isn't a constant. * dsymbol.c: when setting $ for a const variable, don't interpret. (the patch to 3779 is a much better solution). There are three places which were WANTinterpret, but had special treatment when the result wasn't a variable. They are: * mtype.c: static arrays. A[N] could be a template parameter. * statement.c: case statements are allowed to be global variables initialized in 'static this'. * template.c, genIdent(): a template expression could actually be an alias parameter. In each case, I changed it to do a const-fold (WANTvalue), then do the check for TOKvar, and then do optimize(WANTinterpret). * semanticTiargs(). This is yucky. _traits does bad things. int i; __traits(isArithmetic, i+2, i); What the heck is i+2 as a template parameter? It's not a value (i is a runtime variable). It's not an alias. It's not a type. The optimize(WANTinterpret) is silently failing to interpret i, but __traits only needed the type anyway. Fortunately, in semanticTiargs, flags is 1 if and only if it's called from __traits. So I just do a constant fold, instead of an interpret. This fixes bug 1880 "templates instantiated with non-constants should fail sooner", and MANY others. Commit: 47d46bf1364c63df5bb01406db4098c771d701dd https://github.com/D-Programming-Language/dmd/commit/47d46bf1364c63df5bb01406db4098c771d701dd Author: Don Clugston <dclugston at googlemail.com> Date: 2011-04-14 (Thu, 14 Apr 2011) Changed paths: M src/optimize.c Log Message: ----------- 5678 new enum struct re-allocated at compile time If we're interpreting, 'new' should be an error. Commit: 7192ddfb8bf16417882e067f1e14050caae957a9 https://github.com/D-Programming-Language/dmd/commit/7192ddfb8bf16417882e067f1e14050caae957a9 Author: Don Clugston <dclugston at googlemail.com> Date: 2011-04-14 (Thu, 14 Apr 2011) Changed paths: M src/interpret.c M src/optimize.c Log Message: ----------- 4298 Constant array translated to unnecessary array literal creation Uses rsinfu's patch, which works once the patch for bug 3779 is included. I also need to make a little change to CTFE, which can no longer assume that const variables have been expanded. This triggered one failure in Phobos -- but it was a bug: immutable int[1] x =[7]; void main(){ int [] y = x;} // passed, now correctly generates an error Commit: 31528d979827100323ce65e37b9978a49dfd4f79 https://github.com/D-Programming-Language/dmd/commit/31528d979827100323ce65e37b9978a49dfd4f79 Author: Don Clugston <dclugston at googlemail.com> Date: 2011-04-14 (Thu, 14 Apr 2011) Changed paths: M test/runnable/interpret2.d Log Message: ----------- Test cases for 1880 2850 3779 5678 Commit: ed8068f5036f88fff1603d98ebe96bb6659bceed https://github.com/D-Programming-Language/dmd/commit/ed8068f5036f88fff1603d98ebe96bb6659bceed Author: Walter Bright <walter at walterbright.com> Date: 2011-04-14 (Thu, 14 Apr 2011) Changed paths: M src/cond.h M src/dsymbol.c M src/expression.c M src/scope.h M src/statement.c M src/statement.h Log Message: ----------- allow impure code inside debug conditionals Commit: 4e78123b117acc2e5dac2ec4f3de9c6fa3cbb7f1 https://github.com/D-Programming-Language/dmd/commit/4e78123b117acc2e5dac2ec4f3de9c6fa3cbb7f1 Author: Don Clugston <dclugston at googlemail.com> Date: 2011-04-15 (Fri, 15 Apr 2011) Changed paths: M src/struct.c Log Message: ----------- Fix zero-sized fields in struct initializers For things like: struct S { union { int a; int[0] b; int c;} } we need to recognize that a and c are part of the same union. We need to check the size as well as the offset. Commit: 76830bbd9753f65173aa278f72c3ecbc703e7dad https://github.com/D-Programming-Language/dmd/commit/76830bbd9753f65173aa278f72c3ecbc703e7dad Author: Walter Bright <walter at walterbright.com> Date: 2011-04-15 (Fri, 15 Apr 2011) Changed paths: M src/mtype.c Log Message: ----------- void[] may contain pointers Commit: a36005ef0415a25e90c933bf95a08715351248ca https://github.com/D-Programming-Language/dmd/commit/a36005ef0415a25e90c933bf95a08715351248ca Author: Walter Bright <walter at walterbright.com> Date: 2011-04-15 (Fri, 15 Apr 2011) Changed paths: M test/runnable/xtest46.d Log Message: ----------- Merge branch 'master' of github.com:D-Programming-Language/dmd Commit: 2b8c8cb180227a422175e1a356330e52337005c3 https://github.com/D-Programming-Language/dmd/commit/2b8c8cb180227a422175e1a356330e52337005c3 Author: Walter Bright <walter at walterbright.com> Date: 2011-04-15 (Fri, 15 Apr 2011) Changed paths: M src/aggregate.h M src/dsymbol.c M src/init.c M src/interpret.c M src/mtype.c M src/optimize.c M src/statement.c M src/struct.c M src/template.c M test/runnable/interpret2.d Log Message: ----------- Merge branch 'structinit' of https://github.com/donc/dmd into pull27 Compare: https://github.com/D-Programming-Language/dmd/compare/11df108...2b8c8cb |
Copyright © 1999-2021 by the D Language Foundation