Skip to content

Commit

Permalink
fix Issue 18030 - Segmentation fault with __traits(getProtection) on …
Browse files Browse the repository at this point in the history
…template function
  • Loading branch information
WalterBright committed Dec 30, 2017
1 parent de3563f commit 08aca45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/dmd/dsymbolsem.d
Expand Up @@ -151,6 +151,7 @@ const(char)* getMessage(DeprecatedDeclaration dd)
return dd.msgstr;
}


// Returns true if a contract can appear without a function body.
package bool allowsContractWithoutBody(FuncDeclaration funcdecl)
{
Expand Down Expand Up @@ -2074,6 +2075,14 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
if (tempdecl.semanticRun != PASSinit)
return; // semantic() already run

if (tempdecl._scope)
{
sc = tempdecl._scope;
tempdecl._scope = null;
}
if (!sc)
return;

// Remember templates defined in module object that we need to know about
if (sc._module && sc._module.ident == Id.object)
{
Expand Down
18 changes: 18 additions & 0 deletions test/compilable/test18030.d
@@ -0,0 +1,18 @@
// https://issues.dlang.org/show_bug.cgi?id=18030

struct S(T)
{
T var;
pragma(
msg,
"Inside S: func() is ",
__traits(getProtection, __traits(getMember, T, "func"))
);
}

class C
{
alias Al = S!C;

static void func(U)(U var) { }
}

0 comments on commit 08aca45

Please sign in to comment.