Skip to content

Commit

Permalink
Merge pull request #8933 from rainers/capture_name
Browse files Browse the repository at this point in the history
fix issue 19381 - capture pointer in nested function should not be called "this"
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
  • Loading branch information
dlang-bot authored Nov 9, 2018
2 parents e1a88a5 + 7950336 commit 9f1454b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/dmd/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ extern (C++) class FuncDeclaration : Declaration
* enclosing function's stack frame.
* Note that nested functions and member functions are disjoint.
*/
VarDeclaration v = new ThisDeclaration(loc, Type.tvoid.pointerTo());
v.storage_class |= STC.parameter;
VarDeclaration v = new VarDeclaration(loc, Type.tvoid.pointerTo(), Id.capture, null);
v.storage_class |= STC.parameter | STC.nodtor;
if (type.ty == Tfunction)
{
TypeFunction tf = cast(TypeFunction)type;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/id.d
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ immutable Msgtable[] msgtable =
{ "unitTest", "__unitTest" },
{ "require", "__require" },
{ "ensure", "__ensure" },
{ "capture", "__capture" },
{ "_init", "init" },
{ "__sizeof", "sizeof" },
{ "__xalignof", "alignof" },
Expand Down
16 changes: 8 additions & 8 deletions test/runnable/testpdb.d
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ void test19307(IDiaSession session, IDiaSymbol globals)
foo19307();

testClosureVar(globals, "testpdb.foo19307", "__closptr", "x");
testClosureVar(globals, "testpdb.foo19307.nested", "this", "x");
testClosureVar(globals, "testpdb.foo19307.nested", "__capture", "x");
testClosureVar(globals, "testpdb.foo19307.nested", "__closptr", "y");
testClosureVar(globals, "testpdb.foo19307.nested.nested2", "this", "__chain", "x");
testClosureVar(globals, "testpdb.foo19307.nested.nested2", "__capture", "__chain", "x");

testClosureVar(globals, "testpdb.Struct.foo", "__closptr", "this", "member");
testClosureVar(globals, "testpdb.Struct.foo.nested", "this", "localOfMethod");
testClosureVar(globals, "testpdb.Struct.foo.nested", "this", "__chain", "member");
testClosureVar(globals, "testpdb.Struct.foo.nested", "__capture", "localOfMethod");
testClosureVar(globals, "testpdb.Struct.foo.nested", "__capture", "__chain", "member");
}

///////////////////////////////////////////////
Expand All @@ -236,10 +236,10 @@ void test19318(IDiaSession session, IDiaSymbol globals)
foo19318(5);

testClosureVar(globals, "testpdb.foo19318", "x");
testClosureVar(globals, "testpdb.foo19318.nested", "this", "x");
testClosureVar(globals, "testpdb.foo19318.nested", "this", "z");
testClosureVar(globals, "testpdb.foo19318.nested.nested2", "this", "x");
testClosureVar(globals, "testpdb.foo19318.nested.nested2", "this", "z");
testClosureVar(globals, "testpdb.foo19318.nested", "__capture", "x");
testClosureVar(globals, "testpdb.foo19318.nested", "__capture", "z");
testClosureVar(globals, "testpdb.foo19318.nested.nested2", "__capture", "x");
testClosureVar(globals, "testpdb.foo19318.nested.nested2", "__capture", "z");
}

///////////////////////////////////////////////
Expand Down

0 comments on commit 9f1454b

Please sign in to comment.