From 8151b42fa5c2ba8cf4c157da2157f1454677526f Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Sun, 16 Nov 2014 12:12:11 +0100 Subject: [PATCH] do not report deprecation of aggregate during its RTInfo generation --- src/aggregate.h | 2 ++ src/dsymbol.c | 7 ++++++- src/dsymbol.h | 1 + src/struct.c | 18 ++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/aggregate.h b/src/aggregate.h index b8bff41093d5..7b01d34ee6b5 100644 --- a/src/aggregate.h +++ b/src/aggregate.h @@ -73,6 +73,7 @@ class AggregateDeclaration : public ScopeDsymbol Sizeok sizeok; // set when structsize contains valid data Dsymbol *deferred; // any deferred semantic2() or semantic3() symbol bool isdeprecated; // true if deprecated + bool mutedeprecation; // true while analysing RTInfo to avoid deprecation message Dsymbol *enclosing; /* !=NULL if is nested * pointing to the dsymbol that directly enclosing it. @@ -112,6 +113,7 @@ class AggregateDeclaration : public ScopeDsymbol int firstFieldInUnion(int indx); // first field in union that includes indx int numFieldsInUnion(int firstIndex); // #fields in union starting at index bool isDeprecated(); // is aggregate deprecated? + bool muteDeprecationMessage(); // disable deprecation message on Dsymbol? bool isNested(); void makeNested(); bool isExport(); diff --git a/src/dsymbol.c b/src/dsymbol.c index f5adba3cc691..275f50f57edd 100644 --- a/src/dsymbol.c +++ b/src/dsymbol.c @@ -567,6 +567,11 @@ bool Dsymbol::isDeprecated() return false; } +bool Dsymbol::muteDeprecationMessage() +{ + return false; +} + bool Dsymbol::isOverloadable() { return false; @@ -665,7 +670,7 @@ void Dsymbol::deprecation(const char *format, ...) void Dsymbol::checkDeprecated(Loc loc, Scope *sc) { - if (global.params.useDeprecated != 1 && isDeprecated()) + if (global.params.useDeprecated != 1 && isDeprecated() && !muteDeprecationMessage()) { // Don't complain if we're inside a deprecated symbol's scope for (Dsymbol *sp = sc->parent; sp; sp = sp->parent) diff --git a/src/dsymbol.h b/src/dsymbol.h index 80eb12a98aa8..8c8794a4f981 100644 --- a/src/dsymbol.h +++ b/src/dsymbol.h @@ -215,6 +215,7 @@ class Dsymbol : public RootObject virtual bool isExport(); // is Dsymbol exported? virtual bool isImportedSymbol(); // is Dsymbol imported? virtual bool isDeprecated(); // is Dsymbol deprecated? + virtual bool muteDeprecationMessage(); // disable deprecation message on Dsymbol? virtual bool isOverloadable(); virtual bool hasOverloads(); virtual LabelDsymbol *isLabel(); // is this a LabelDsymbol? diff --git a/src/struct.c b/src/struct.c index 354b8985ea44..867a85d3a77c 100644 --- a/src/struct.c +++ b/src/struct.c @@ -137,6 +137,7 @@ AggregateDeclaration::AggregateDeclaration(Loc loc, Identifier *id) sizeok = SIZEOKnone; // size not determined yet deferred = NULL; isdeprecated = false; + mutedeprecation = false; inv = NULL; aggNew = NULL; aggDelete = NULL; @@ -238,6 +239,16 @@ void AggregateDeclaration::semantic3(Scope *sc) (!isDeprecated() || global.params.useDeprecated) && (type && type->ty != Terror)) { + // we do not want to report deprecated uses of this type during RTInfo + // generation, so we disable reporting deprecation temporarily + // WARNING: Muting messages during analysis of RTInfo might silently instantiate + // templates that use (other) deprecated types. If these template instances + // are used in other parts of the program later, they will be reused without + // ever producing the deprecation message. The implementation here restricts + // muting to the types that RTInfo is currently generated for. + bool wasmuted = mutedeprecation; + mutedeprecation = true; + // Evaluate: RTinfo!type Objects *tiargs = new Objects(); tiargs->push(type); @@ -255,6 +266,8 @@ void AggregateDeclaration::semantic3(Scope *sc) e = e->ctfeInterpret(); getRTInfo = e; + + mutedeprecation = wasmuted; } if (sd) @@ -384,6 +397,11 @@ bool AggregateDeclaration::isDeprecated() return isdeprecated; } +bool AggregateDeclaration::muteDeprecationMessage() +{ + return mutedeprecation; +} + bool AggregateDeclaration::isExport() { return protection.kind == PROTexport;