Mercurial > projects > ldc
changeset 631:9fcb5f1a4c54
Automated merge with http://hg.dsource.org/projects/llvmdc
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Wed, 01 Oct 2008 21:14:20 +0200 |
parents | 607b6b5819a7 (current diff) bc83491463f0 (diff) |
children | d208fc4291df |
files | |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/mtype.c Wed Oct 01 20:55:13 2008 +0200 +++ b/dmd/mtype.c Wed Oct 01 21:14:20 2008 +0200 @@ -2934,6 +2934,14 @@ arg->defaultArg = arg->defaultArg->semantic(sc); arg->defaultArg = resolveProperties(sc, arg->defaultArg); arg->defaultArg = arg->defaultArg->implicitCastTo(sc, arg->type); + + // make sure default arguments only use variables with lower protection + // this check only catches the common case that the default arg Exp is a VarExp + if(arg->defaultArg->op == TOKvar) + { VarExp *ve = (VarExp *)arg->defaultArg; + if(ve->var->protection < sc->protection) + error(loc, "default argument %s has stronger protection than function %s", ve->var->toChars(), toChars()); + } } /* If arg turns out to be a tuple, the number of parameters may