diff options
Diffstat (limited to 'gcc/d/dmd/func.d')
-rw-r--r-- | gcc/d/dmd/func.d | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/d/dmd/func.d b/gcc/d/dmd/func.d index 39cb8456fda..afc0ebbee16 100644 --- a/gcc/d/dmd/func.d +++ b/gcc/d/dmd/func.d @@ -549,9 +549,22 @@ extern (C++) class FuncDeclaration : Declaration if (thandle.ty == Tstruct) { vthis.storage_class |= STC.ref_; - // if member function is marked 'inout', then 'this' is 'return ref' - if (type.ty == Tfunction && (cast(TypeFunction)type).isInOutQual()) - vthis.storage_class |= STC.return_; + + /* if member function is marked 'inout', then 'this' is 'return ref' + * The same thing is done for `ref inout` parameters in TypeFunction's semantic routine. + */ + if (auto tf = type.isTypeFunction()) + { + /* This feature was a mistake, but existing code relies on it. + * So only disable it in @safe code and DIP1000 code + */ + if (!(global.params.useDIP1000 == FeatureState.enabled && + tf.trust == TRUST.safe)) + { + if (tf.isInOutQual()) + vthis.storage_class |= STC.return_; + } + } } } |