Skip to content

Commit

Permalink
Merge pull request dlang#4793 from 9rnsr/fix14753
Browse files Browse the repository at this point in the history
Issue 14753 - pragma(inline) hides the alias "string"
  • Loading branch information
WalterBright authored and 9rnsr committed Jul 6, 2015
1 parent 22e27f5 commit cbab6d6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
15 changes: 6 additions & 9 deletions src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,6 @@ Scope *PragmaDeclaration::newScope(Scope *sc)
inlining = PINLINEnever;
}

if (decl)
{
for (size_t i = 0; i < decl->dim; i++)
{
Dsymbol *s = (*decl)[i];
s->semantic(sc);
}
}
return createNewScope(sc, sc->stc, sc->linkage, sc->protection, sc->explicitProtection, sc->structalign, inlining);
}
return sc;
Expand Down Expand Up @@ -1080,11 +1072,13 @@ void PragmaDeclaration::semantic(Scope *sc)
Ldecl:
if (decl)
{
Scope *sc2 = newScope(sc);

for (size_t i = 0; i < decl->dim; i++)
{
Dsymbol *s = (*decl)[i];

s->semantic(sc);
s->semantic(sc2);

if (ident == Id::mangle)
{
Expand All @@ -1101,6 +1095,9 @@ void PragmaDeclaration::semantic(Scope *sc)
}
}
}

if (sc2 != sc)
sc2->pop();
}
return;

Expand Down
21 changes: 18 additions & 3 deletions test/fail_compilation/pragmainline2.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
REQUIRED_ARGS: -inline
TEST_OUTPUT:
---
fail_compilation/pragmainline2.d(12): Error: function pragmainline2.foo cannot inline function
fail_compilation/pragmainline2.d(14): Error: function pragmainline2.foo cannot inline function
fail_compilation/pragmainline2.d(22): Error: function pragmainline2.f1t cannot inline function
fail_compilation/pragmainline2.d(25): Error: function pragmainline2.f2t cannot inline function
---
*/

Expand All @@ -13,12 +15,25 @@ void foo()
{
pragma(inline, false);
pragma(inline);
pragma(inline, true);
pragma(inline, true); // this last one will affect to the 'foo'
while (0) { }
}

pragma(inline, true) void f1t() { while (0) {} } // cannot inline
pragma(inline, false) void f1f() { while (0) {} }
pragma(inline) void f1d() { while (0) {} }
void f2t() { pragma(inline, true); while (0) {} } // cannot inline
void f2f() { pragma(inline, false); while (0) {} }
void f2d() { pragma(inline); while (0) {} }

void main()
{
foo();
}

f1t();
f1f();
f1d();
f2t();
f2f();
f2d();
}
6 changes: 6 additions & 0 deletions test/runnable/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,12 @@ void test14606()
auto t = T14606(null);
}

/**********************************/
// 14753

pragma(inline)
void test14753(string) { }

/**********************************/

int main()
Expand Down

0 comments on commit cbab6d6

Please sign in to comment.