# HG changeset patch # User Christian Kamm # Date 1222888460 -7200 # Node ID 9fcb5f1a4c54640e499eaa96fc3db4b0a6815324 # Parent 607b6b5819a79d10f06b981a2d448f797f3bf2ec# Parent bc83491463f04965194c659d6df33a86bc4716be Automated merge with http://hg.dsource.org/projects/llvmdc diff -r 607b6b5819a7 -r 9fcb5f1a4c54 dmd/mtype.c --- 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