Michel Fortin, el 13 de julio a las 15:54 me escribiste: > Le 2011-07-13 à 13:00, Leandro Lucarella a écrit : > > > OK, I download and compiled druntime with all -d, -di and none and > > couldn't reproduce this problem. > > Today I rebased yesterday's changes on the latest master instead of the > yesterday's master, then I updated druntime to the latest master too, then > all went well, compiling druntime, phobos and the dmd test suite. > > I'm not sure what went wrong yesterday. I'm pretty sure I did test both with > and without your patch to make sure the master wasn't the problem, but > perhaps I just did that wrong. > > > [...] > > 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. > > This new patch seems to work fine too. > > Here is a new pull request: > <https://github.com/D-Programming-Language/dmd/pull/248>
Thanks! Here are a couple new patches that tidy up things a little further. In the way, I noticed there were some features what were reported as deprecated, but were really plain errors, since they were issued when this condition is met: 1 || !global.params.useDeprecated, i.e. always :) In this patch I thread that as plain errors (and change "deprecated" with "no longer legal", as it says with other removed features). If we really want a deprecation message there, is trivial to do so (change error() with deprecation()). If you can include this one too, it would be awesome! =) Thanks! -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- El otro día tenía un plan Pero después me olvidé y me comí un flan
>From 4ac02d2a51a3516f5dd5d833e6e655c55022e09c Mon Sep 17 00:00:00 2001 From: Leandro Lucarella <[email protected]> Date: Wed, 13 Jul 2011 17:33:29 -0300 Subject: [PATCH] Make deprecated() smarter The deprecated() function now checks if a deprecation message should be emitted at all, so you can now call deprecated() without checking if global.params.deprecation is not 0 yourself. This makes code easier to write and read. Also restore some error messages that had "deprecated" in them but were really plain errors (things that are not longer legal at all, not just deprecated). --- src/dsymbol.c | 2 +- src/expression.c | 20 +++++--------------- src/iasm.c | 3 +-- src/lexer.c | 21 +++++++++------------ src/mars.c | 12 ++++++++---- src/module.c | 4 ++-- src/mtype.c | 12 ++++-------- src/parse.c | 17 +++++------------ src/statement.c | 3 +-- 9 files changed, 36 insertions(+), 58 deletions(-) diff --git a/src/dsymbol.c b/src/dsymbol.c index dafecb6..830cc44 100644 --- a/src/dsymbol.c +++ b/src/dsymbol.c @@ -1112,7 +1112,7 @@ Dsymbol *ArrayScopeSymbol::search(Loc loc, Identifier *ident, int flags) { VarDeclaration **pvar; Expression *ce; - if (ident == Id::length && global.params.deprecation) + if (ident == Id::length) deprecation("using 'length' inside [ ] is deprecated, use '$' instead"); L1: diff --git a/src/expression.c b/src/expression.c index 5f88c85..926acdc 100644 --- a/src/expression.c +++ b/src/expression.c @@ -5325,8 +5325,7 @@ Expression *IsExp::semantic(Scope *sc) break; case TOKinvariant: - if (global.params.deprecation) - deprecation("use of 'invariant' rather than 'immutable' is deprecated"); + deprecation("use of 'invariant' rather than 'immutable' is deprecated"); case TOKimmutable: if (!targ->isImmutable()) goto Lno; @@ -8161,9 +8160,7 @@ Expression *DeleteExp::semantic(Scope *sc) IndexExp *ae = (IndexExp *)(e1); Type *tb1 = ae->e1->type->toBasetype(); if (tb1->ty == Taarray) - { if (global.params.deprecation) - deprecation("delete aa[key] deprecated, use aa.remove(key)"); - } + deprecation("delete aa[key] deprecated, use aa.remove(key)"); } return this; @@ -9314,16 +9311,9 @@ Expression *AssignExp::semantic(Scope *sc) { // Rewrite (a[i] = value) to (a.opIndex(i, value)) if (search_function(ad, id)) - { Expression *e = new DotIdExp(loc, ae->e1, id); - - if (global.params.deprecation) - { deprecation("operator [] assignment overload with opIndex(i, value) illegal, use opIndexAssign(value, i)"); - return new ErrorExp(); - } - - e = new CallExp(loc, e, (Expression *)ae->arguments->data[0], e2); - e = e->semantic(sc); - return e; + { + deprecation("operator [] assignment overload with opIndex(i, value) illegal, use opIndexAssign(value, i)"); + return new ErrorExp(); } } #endif diff --git a/src/iasm.c b/src/iasm.c index 91da7b7..666cce2 100644 --- a/src/iasm.c +++ b/src/iasm.c @@ -3968,8 +3968,7 @@ STATIC OPND *asm_una_exp() // Check for offset keyword if (asmtok->ident == Id::offset) { - if (global.params.deprecation) - deprecation(asmstate.loc, "offset deprecated, use offsetof"); + deprecation(asmstate.loc, "offset deprecated, use offsetof"); goto Loffset; } if (asmtok->ident == Id::offsetof) diff --git a/src/lexer.c b/src/lexer.c index 5f1e445..540fef0 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -339,7 +339,7 @@ void Lexer::deprecation(const char *format, ...) ::vdeprecation(loc, format, ap); va_end(ap); - if (global.params.deprecation > 1 && + if (global.params.deprecation == 2 && global.warnings >= 20) // moderate blizzard of cascading messages fatal(); else if (global.params.deprecation == 1 && @@ -348,7 +348,7 @@ void Lexer::deprecation(const char *format, ...) } else { - if (global.params.deprecation > 1) + if (global.params.deprecation == 2) global.warnings++; else global.errors++; @@ -364,7 +364,7 @@ void Lexer::deprecation(Loc loc, const char *format, ...) ::vdeprecation(loc, format, ap); va_end(ap); - if (global.params.deprecation > 1 && + if (global.params.deprecation == 2 && global.warnings >= 20) // moderate blizzard of cascading messages fatal(); else if (global.params.deprecation == 1 && @@ -373,7 +373,7 @@ void Lexer::deprecation(Loc loc, const char *format, ...) } else { - if (global.params.deprecation > 1) + if (global.params.deprecation == 1) global.warnings++; else global.errors++; @@ -660,8 +660,7 @@ void Lexer::scan(Token *t) t->postfix = 0; t->value = TOKstring; #if DMDV2 - if (global.params.deprecation) - deprecation("Escape String literal %.*s is deprecated, use double quoted string literal \"%.*s\" instead", p - pstart, pstart, p - pstart, pstart); + deprecation("Escape String literal %.*s is deprecated, use double quoted string literal \"%.*s\" instead", p - pstart, pstart, p - pstart, pstart); #endif return; } @@ -2310,8 +2309,7 @@ done: goto L1; case 'l': - if (1 || global.params.deprecation) - deprecation("'l' suffix is deprecated, use 'L' instead"); + error("'l' suffix is no longer legal, use 'L' instead"); case 'L': f = FLAGS_long; L1: @@ -2326,7 +2324,7 @@ done: break; } - if (state == STATE_octal && n >= 8 && global.params.deprecation) + if (state == STATE_octal && n >= 8) deprecation("octal literals 0%llo%.*s are deprecated, use std.conv.octal!%llo%.*s instead", n, p - psuffix, psuffix, n, p - psuffix, psuffix); @@ -2558,8 +2556,7 @@ done: break; case 'l': - if (global.params.deprecation) - deprecation("'l' suffix is deprecated, use 'L' instead"); + error("'l' suffix is no longer legal, use 'L' instead"); case 'L': result = TOKfloat80v; p++; @@ -2567,7 +2564,7 @@ done: } if (*p == 'i' || *p == 'I') { - if (global.params.deprecation && *p == 'I') + if (*p == 'I') deprecation("'I' suffix is deprecated, use 'i' instead"); p++; switch (result) diff --git a/src/mars.c b/src/mars.c index 7506a43..7149dcb 100644 --- a/src/mars.c +++ b/src/mars.c @@ -218,15 +218,19 @@ void vwarning(Loc loc, const char *format, va_list ap) void vdeprecation(Loc loc, const char *format, va_list ap) { - if (global.params.deprecation > 1) + char oldw; + switch (global.params.deprecation) { - char oldw = global.params.warnings; + case 2: + oldw = global.params.warnings; global.params.warnings = 2; // activate informational warnings temporarly vwarning(loc, format, ap); global.params.warnings = oldw; - } - else + break; + case 1: verror(loc, format, ap); + break; + } } /*************************************** diff --git a/src/module.c b/src/module.c index 851b424..c0ff183 100644 --- a/src/module.c +++ b/src/module.c @@ -128,8 +128,8 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen if (srcfilename->equalsExt("html") || srcfilename->equalsExt("htm") || srcfilename->equalsExt("xhtml")) - { if (global.params.deprecation) - deprecation("html source files is deprecated %s", srcfilename->toChars()); + { + deprecation("html source files is deprecated %s", srcfilename->toChars()); isHtml = 1; } else diff --git a/src/mtype.c b/src/mtype.c index 94f918b..8fa1c2d 100644 --- a/src/mtype.c +++ b/src/mtype.c @@ -1699,8 +1699,7 @@ Expression *Type::getProperty(Loc loc, Identifier *ident) } else if (ident == Id::typeinfo) { - if (global.params.deprecation) - deprecation(loc, ".typeinfo deprecated, use typeid(type)"); + deprecation(loc, ".typeinfo deprecated, use typeid(type)"); e = getTypeInfo(NULL); } else if (ident == Id::init) @@ -1768,8 +1767,7 @@ Expression *Type::dotExp(Scope *sc, Expression *e, Identifier *ident) { if (ident == Id::offset) { - if (global.params.deprecation) - deprecation(e->loc, ".offset deprecated, use .offsetof"); + deprecation(e->loc, ".offset deprecated, use .offsetof"); goto Loffset; } else if (ident == Id::offsetof) @@ -1818,8 +1816,7 @@ Expression *Type::dotExp(Scope *sc, Expression *e, Identifier *ident) } if (ident == Id::typeinfo) { - if (global.params.deprecation) - deprecation(e->loc, ".typeinfo deprecated, use typeid(type)"); + deprecation(e->loc, ".typeinfo deprecated, use typeid(type)"); e = getTypeInfo(sc); } else if (ident == Id::stringof) @@ -7542,8 +7539,7 @@ L1: if (ident == Id::typeinfo) { - if (global.params.deprecation) - deprecation(e->loc, ".typeinfo deprecated, use typeid(type)"); + deprecation(e->loc, ".typeinfo deprecated, use typeid(type)"); return getTypeInfo(sc); } if (ident == Id::outer && sym->vthis) diff --git a/src/parse.c b/src/parse.c index 9ece86f..9d9b0b7 100644 --- a/src/parse.c +++ b/src/parse.c @@ -668,8 +668,7 @@ StorageClass Parser::parsePostfix() { case TOKconst: stc |= STCconst; break; case TOKinvariant: - if (global.params.deprecation) - deprecation("use of 'invariant' rather than 'immutable' is deprecated"); + deprecation("use of 'invariant' rather than 'immutable' is deprecated"); case TOKimmutable: stc |= STCimmutable; break; case TOKshared: stc |= STCshared; break; case TOKwild: stc |= STCwild; break; @@ -2337,8 +2336,7 @@ Type *Parser::parseBasicType() break; case TOKinvariant: - if (global.params.deprecation) - deprecation("use of 'invariant' rather than 'immutable' is deprecated"); + deprecation("use of 'invariant' rather than 'immutable' is deprecated"); case TOKimmutable: // invariant(type) nextToken(); @@ -2503,10 +2501,7 @@ Type *Parser::parseDeclarator(Type *t, Identifier **pident, TemplateParameters * * although the D style would be: * int[]*[3] ident */ - if (global.params.deprecation) - { - deprecation("C-style function pointer and pointer to array syntax is deprecated. Use 'function' to declare function pointers"); - } + deprecation("C-style function pointer and pointer to array syntax is deprecated. Use 'function' to declare function pointers"); nextToken(); ts = parseDeclarator(t, pident); check(TOKrparen); @@ -3792,8 +3787,7 @@ Statement *Parser::parseStatement(int flags) arg = new Parameter(0, NULL, token.ident, NULL); nextToken(); nextToken(); - if (1 || global.params.deprecation) - deprecation("if (v; e) is deprecated, use if (auto v = e)"); + error("if (v; e) is no longer legal, use if (auto v = e)"); } } @@ -4159,8 +4153,7 @@ Statement *Parser::parseStatement(int flags) nextToken(); s = parseStatement(PSsemi | PScurlyscope); #if DMDV2 - if (global.params.deprecation) - deprecation("volatile statements deprecated; used synchronized statements instead"); + deprecation("volatile statements deprecated; used synchronized statements instead"); #endif s = new VolatileStatement(loc, s); break; diff --git a/src/statement.c b/src/statement.c index dd2228a..f6d6994 100644 --- a/src/statement.c +++ b/src/statement.c @@ -2866,8 +2866,7 @@ Statement *SwitchStatement::semantic(Scope *sc) if (!sc->sw->sdefault && !isFinal) { hasNoDefault = 1; - if (global.params.deprecation) - deprecation("non-final switch statement without a default is deprecated"); + deprecation("non-final switch statement without a default is deprecated"); // Generate runtime error if the default is hit Statements *a = new Statements(); -- 1.7.5.4
_______________________________________________ dmd-internals mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/dmd-internals
