@@ -216,7 +216,7 @@ pure @safe:
216216 }
217217 }
218218
219- char [] append ( const (char )[] val )
219+ char [] append ( const (char )[] val ) return scope
220220 {
221221 pragma (inline, false ); // tame dmd inliner
222222
@@ -253,13 +253,13 @@ pure @safe:
253253 put(" , " );
254254 }
255255
256- char [] put (char c)
256+ char [] put (char c) return scope
257257 {
258258 char [1 ] val = c;
259259 return put (val[]);
260260 }
261261
262- char [] put ( const (char )[] val ) return
262+ char [] put ( scope const (char )[] val ) return scope
263263 {
264264 pragma (inline, false ); // tame dmd inliner
265265
@@ -430,7 +430,7 @@ pure @safe:
430430 Digit
431431 Digit Number
432432 */
433- const (char )[] sliceNumber ()
433+ const (char )[] sliceNumber () return scope
434434 {
435435 debug (trace) printf( " sliceNumber+\n " );
436436 debug (trace) scope (success) printf( " sliceNumber-\n " );
@@ -448,7 +448,7 @@ pure @safe:
448448 }
449449
450450
451- size_t decodeNumber ()
451+ size_t decodeNumber () scope
452452 {
453453 debug (trace) printf( " decodeNumber+\n " );
454454 debug (trace) scope (success) printf( " decodeNumber-\n " );
@@ -457,7 +457,7 @@ pure @safe:
457457 }
458458
459459
460- size_t decodeNumber ( const (char )[] num )
460+ size_t decodeNumber ( scope const (char )[] num ) scope
461461 {
462462 debug (trace) printf( " decodeNumber+\n " );
463463 debug (trace) scope (success) printf( " decodeNumber-\n " );
@@ -478,7 +478,7 @@ pure @safe:
478478 }
479479
480480
481- void parseReal ()
481+ void parseReal () scope
482482 {
483483 debug (trace) printf( " parseReal+\n " );
484484 debug (trace) scope (success) printf( " parseReal-\n " );
@@ -569,7 +569,7 @@ pure @safe:
569569 Namechar
570570 Namechar Namechars
571571 */
572- void parseLName ()
572+ void parseLName () scope
573573 {
574574 debug (trace) printf( " parseLName+\n " );
575575 debug (trace) scope (success) printf( " parseLName-\n " );
@@ -787,7 +787,7 @@ pure @safe:
787787 TypeTuple:
788788 B Number Arguments
789789 */
790- char [] parseType ( char [] name = null ) return
790+ char [] parseType ( char [] name = null ) return scope
791791 {
792792 static immutable string [23 ] primitives = [
793793 " char" , // a
@@ -1196,7 +1196,7 @@ pure @safe:
11961196 }
11971197 }
11981198
1199- void parseFuncArguments ()
1199+ void parseFuncArguments () scope
12001200 {
12011201 // Arguments
12021202 for ( size_t n = 0 ; true ; n++ )
@@ -1353,7 +1353,7 @@ pure @safe:
13531353 E
13541354 F
13551355 */
1356- void parseValue ( char [] name = null , char type = ' \0 ' )
1356+ void parseValue (scope char [] name = null , char type = ' \0 ' ) scope
13571357 {
13581358 debug (trace) printf( " parseValue+\n " );
13591359 debug (trace) scope (success) printf( " parseValue-\n " );
@@ -1474,7 +1474,7 @@ pure @safe:
14741474 }
14751475
14761476
1477- void parseIntegerValue ( char [] name = null , char type = ' \0 ' )
1477+ void parseIntegerValue ( scope char [] name = null , char type = ' \0 ' ) scope
14781478 {
14791479 debug (trace) printf( " parseIntegerValue+\n " );
14801480 debug (trace) scope (success) printf( " parseIntegerValue-\n " );
@@ -1584,7 +1584,7 @@ pure @safe:
15841584 S Number_opt QualifiedName
15851585 X ExternallyMangledName
15861586 */
1587- void parseTemplateArgs ()
1587+ void parseTemplateArgs () scope
15881588 {
15891589 debug (trace) printf( " parseTemplateArgs+\n " );
15901590 debug (trace) scope (success) printf( " parseTemplateArgs-\n " );
@@ -1718,7 +1718,7 @@ pure @safe:
17181718 TemplateInstanceName:
17191719 Number __T LName TemplateArgs Z
17201720 */
1721- void parseTemplateInstanceName (bool hasNumber)
1721+ void parseTemplateInstanceName (bool hasNumber) scope
17221722 {
17231723 debug (trace) printf( " parseTemplateInstanceName+\n " );
17241724 debug (trace) scope (success) printf( " parseTemplateInstanceName-\n " );
@@ -1743,7 +1743,7 @@ pure @safe:
17431743 }
17441744
17451745
1746- bool mayBeTemplateInstanceName ()
1746+ bool mayBeTemplateInstanceName () scope
17471747 {
17481748 debug (trace) printf( " mayBeTemplateInstanceName+\n " );
17491749 debug (trace) scope (success) printf( " mayBeTemplateInstanceName-\n " );
@@ -1763,7 +1763,7 @@ pure @safe:
17631763 LName
17641764 TemplateInstanceName
17651765 */
1766- void parseSymbolName ()
1766+ void parseSymbolName () scope
17671767 {
17681768 debug (trace) printf( " parseSymbolName+\n " );
17691769 debug (trace) scope (success) printf( " parseSymbolName-\n " );
@@ -1805,7 +1805,7 @@ pure @safe:
18051805
18061806 // parse optional function arguments as part of a symbol name, i.e without return type
18071807 // if keepAttr, the calling convention and function attributes are not discarded, but returned
1808- char [] parseFunctionTypeNoReturn ( bool keepAttr = false )
1808+ char [] parseFunctionTypeNoReturn ( bool keepAttr = false ) return scope
18091809 {
18101810 // try to demangle a function, in case we are pointing to some function local
18111811 auto prevpos = pos;
@@ -1856,7 +1856,7 @@ pure @safe:
18561856 SymbolName
18571857 SymbolName QualifiedName
18581858 */
1859- char [] parseQualifiedName () return
1859+ char [] parseQualifiedName () return scope
18601860 {
18611861 debug (trace) printf( " parseQualifiedName+\n " );
18621862 debug (trace) scope (success) printf( " parseQualifiedName-\n " );
@@ -1880,7 +1880,7 @@ pure @safe:
18801880 _D QualifiedName Type
18811881 _D QualifiedName M Type
18821882 */
1883- void parseMangledName ( bool displayType, size_t n = 0 )
1883+ void parseMangledName ( bool displayType, size_t n = 0 ) scope
18841884 {
18851885 debug (trace) printf( " parseMangledName+\n " );
18861886 debug (trace) scope (success) printf( " parseMangledName-\n " );
@@ -1955,7 +1955,7 @@ pure @safe:
19551955 parseMangledName( AddType.yes == addType );
19561956 }
19571957
1958- char [] copyInput ()
1958+ char [] copyInput () return scope
19591959 {
19601960 if (dst.length < buf.length)
19611961 dst.length = buf.length;
@@ -1964,7 +1964,7 @@ pure @safe:
19641964 return r;
19651965 }
19661966
1967- char [] doDemangle (alias FUNC )()
1967+ char [] doDemangle (alias FUNC )() return scope
19681968 {
19691969 while ( true )
19701970 {
@@ -2080,7 +2080,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
20802080 Replacement [] replacements;
20812081
20822082 pure @safe :
2083- size_t positionInResult (size_t pos)
2083+ size_t positionInResult (size_t pos) scope
20842084 {
20852085 foreach_reverse (r; replacements)
20862086 if (pos >= r.pos)
@@ -2090,7 +2090,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
20902090
20912091 alias Remangle = Demangle! (PrependHooks);
20922092
2093- void flushPosition (ref Remangle d)
2093+ void flushPosition (ref Remangle d) scope
20942094 {
20952095 if (lastpos < d.pos)
20962096 {
@@ -2109,7 +2109,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
21092109 }
21102110 }
21112111
2112- bool parseLName (ref Remangle d)
2112+ bool parseLName (scope ref Remangle d) scope
21132113 {
21142114 flushPosition(d);
21152115
@@ -2140,7 +2140,8 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
21402140 npos = positionInResult(* pid);
21412141 }
21422142 encodeBackref(reslen - npos);
2143- replacements ~= Replacement(d.pos, result.length);
2143+ const pos = d.pos; // work around issues.dlang.org/show_bug.cgi?id=20675
2144+ replacements ~= Replacement(pos, result.length);
21442145 }
21452146 else
21462147 {
@@ -2154,7 +2155,8 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
21542155 size_t npos = positionInResult(* pid);
21552156 result.length = reslen;
21562157 encodeBackref(reslen - npos);
2157- replacements ~= Replacement(d.pos, result.length);
2158+ const pos = d.pos; // work around issues.dlang.org/show_bug.cgi?id=20675
2159+ replacements ~= Replacement(pos, result.length);
21582160 }
21592161 else
21602162 {
@@ -2166,7 +2168,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
21662168 return true ;
21672169 }
21682170
2169- char [] parseType ( ref Remangle d, char [] name = null ) return
2171+ char [] parseType ( ref Remangle d, char [] name = null ) return scope
21702172 {
21712173 if (d.front != ' Q' )
21722174 return null ;
@@ -2187,7 +2189,7 @@ char[] reencodeMangled(const(char)[] mangled) nothrow pure @safe
21872189 return result[reslen .. $]; // anything but null
21882190 }
21892191
2190- void encodeBackref (size_t relpos)
2192+ void encodeBackref (size_t relpos) scope
21912193 {
21922194 result ~= ' Q' ;
21932195 enum base = 26 ;
0 commit comments