[dmd-internals] Deprecation warnings and a trivial man page patch

Leandro Lucarella luca at llucax.com.ar
Wed Jul 13 10:00:09 PDT 2011


Leandro Lucarella, el 13 de julio a las 01:16 me escribiste:
> Michel Fortin, el 12 de julio a las 21:40 me escribiste:
> > Le 2011-07-12 à 19:32, Leandro Lucarella a écrit :
> > 
> > > Hi, I just wanted to hand you a patch I did to add a new option to show
> > > deprecation messages as warnings (-di), following the discussion in the
> > > announcement group. I know I should probably get an account in github
> > > and do those pull requests everybody talks about, but it's too much
> > > trouble for an occasional collaboration, I hope you are willing to take
> > > a look at the patches and apply them if you like them (and if not, any
> > > feedback would be appreciated). I didn't do a lot of testing either,
> > > because is not trivial at all to set up a testing environment for the
> > > compiler, so testing would be appreciated too (I know is easy to run the
> > > test suite once you have a proper development environment set up). See
> > > the patch descriptions for more details.
> > > 
> > > I hope you find the patches useful.
> > 
> > Turned them into pull requests.
> > 
> > <https://github.com/D-Programming-Language/dmd/pull/244>
> > <https://github.com/D-Programming-Language/dmd/pull/245>
> > 
> > But then I had to close the pull request about deprecation warnings.
> > 
> > Not only it fails the test suite (I should have checked sooner), but for some strange reasons it generates errors while compiling druntime, and those errors aren't fatal as they should and thus don't prevent the build from being successful. They're also pretty strange considering the nature of the changes:
> > 
> > src/core/thread.d(3723): Error: undefined identifier ucontext_t
> > src/core/thread.d(2845): Error: undefined identifier GetSystemInfo
> > src/core/thread.d(2854): Error: undefined identifier _SC_PAGESIZE
> > src/core/thread.d(2895): Error: undefined identifier ucontext_t
> > src/core/thread.d(3199): Error: undefined identifier ucontext_t
> > src/core/thread.d(3206): Error: undefined identifier ucontext_t
> > src/core/thread.d(3302): Error: undefined identifier ucontext_t
> > src/core/thread.d(3332): Error: undefined identifier ucontext_t
> > src/core/thread.d(3370): Error: undefined identifier ucontext_t
> > src/core/thread.d(3464): Error: undefined identifier VirtualAlloc
> > src/core/thread.d(3574): Error: undefined identifier VirtualAlloc
> 
> OK, all that errors have an static if (__tratits(compiles, symbol))
> 
> I'll try to figure out what's making the mess with __traits(compiles)...

OK, I download and compiled druntime with all -d, -di and none and
couldn't reproduce this problem. I got another errors though:

src/core/runtime.d(310): Error: function core.runtime.backtrace (void**, uint) is not callable using argument types (void*[128u],int)
src/core/runtime.d(310): Error: cannot implicitly convert expression (callstack) of type void*[128u] to void**
src/core/runtime.d(311): Error: function core.runtime.backtrace_symbols_fd (void**, int, int) is not callable
using argument types (void*[128u],int,int)
src/core/runtime.d(311): Error: cannot implicitly convert expression (callstack) of type void*[128u] to void**

I fixed them by changing just one line in the patch:

--- a/src/mtype.c
+++ b/src/mtype.c
@@ -56,7 +56,7 @@ FuncDeclaration *hasThis(Scope *sc);
 #define LOGDEFAULTINIT  0       // log ::defaultInit()
 
 // Allow implicit conversion of T[] to T*
-#define IMPLICIT_ARRAY_TO_PTR   (!global.params.deprecation)
+#define IMPLICIT_ARRAY_TO_PTR   (global.params.deprecation != 1)
 
 /* These have default values for 32 bit code, they get
  * adjusted for 64 bit code.

The problem is, this type of deprecation can't show a warning, I guess,
because it just add or removes functions as possible candidates, I tried
to make it show a sensible warning but couldn't find a way without
getting a lot of spurious warnings, maybe someone who knows better can
fix this though. Worst case, we have to decide if -di should die with an
error of an unmatched function or if it should pass silently (what I did
in this new patch).

Also I fixed another small bug that could prevent some warnings to be
shown:

--- a/src/mars.c
+++ b/src/mars.c
@@ -159,10 +159,7 @@ void deprecation(Loc loc, const char *format, ...)
 {
     va_list ap;
     va_start(ap, format);
-    if (global.params.deprecation > 1)
-        vwarning(loc, format, ap);
-    else
-        verror(loc, format, ap);
+    vdeprecation(loc, format, ap);
     va_end( ap );
 }
 
Attached is the updated patch. If you can try it, it would be appreciated, and
if it's still failing, I would appreciate if you can give me detailed steps to
reproduce it.

Thanks!

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Every day 21 new born babies will be given to the wrong parents
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-option-to-show-deprecated-errors-as-warnings.patch
Type: text/x-diff
Size: 28977 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20110713/a178c31e/attachment-0001.patch>


More information about the dmd-internals mailing list