Skip to content

Commit

Permalink
Merge pull request #4316 from 9rnsr/fix13860
Browse files Browse the repository at this point in the history
Issue 13860 - template required forward reference for typeof(member)
  • Loading branch information
yebblies committed Jan 20, 2015
2 parents 5085b5d + 3a5c42c commit 661f23d
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/declaration.c
Expand Up @@ -864,13 +864,11 @@ void VarDeclaration::semantic(Scope *sc)
if (sc->func->setUnsafe())
error("__gshared not allowed in safe functions; use shared");
}
if (type->hasPointers()) // get type size
if (init && init->isVoidInitializer() &&
type->hasPointers()) // get type size
{
if (init && init->isVoidInitializer())
{
if (sc->func->setUnsafe())
error("void initializers for pointers not allowed in safe functions");
}
if (sc->func->setUnsafe())
error("void initializers for pointers not allowed in safe functions");
}
}

Expand Down
27 changes: 27 additions & 0 deletions test/compilable/fwdref13860.d
@@ -0,0 +1,27 @@
// PERMUTE_ARGS:
/*
TEST_OUTPUT:
---
pure nothrow @nogc @safe void()
pure nothrow @nogc @safe void()
---
*/

struct Foo(Bar...)
{
Bar bars;
auto baz(size_t d)() {}
pragma(msg, typeof(baz!0));
}

auto bar(S, R)(S s, R r)
{
pragma(msg, typeof(Foo!().baz!0));
}

void main()
{
int[] x;
int[] y;
x.bar(y);
}
2 changes: 1 addition & 1 deletion test/fail_compilation/ice12350.d
@@ -1,12 +1,12 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice12350.d(10): Error: enum ice12350.MyUDC is forward referenced looking for base type
fail_compilation/ice12350.d(15): Error: type MyUDC has no value
fail_compilation/ice12350.d(30): Error: template instance ice12350.testAttrs!(MyStruct) error instantiating
---
*/


enum MyUDC;

struct MyStruct
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/ice12362.d
@@ -1,12 +1,12 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice12362.d(9): Error: enum ice12362.foo is forward referenced looking for base type
fail_compilation/ice12362.d(12): Error: cannot interpret foo at compile time
---
*/

enum foo;

void main()
{
enum bar = foo;
Expand Down
2 changes: 1 addition & 1 deletion test/fail_compilation/ice13225.d
@@ -1,10 +1,10 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice13225.d(12): Error: mixin ice13225.S.M!(function (S _param_0) => 0) does not match template declaration M(T)
fail_compilation/ice13225.d(13): Error: undefined identifier undefined
---
*/

mixin template M(T) {}

struct S
Expand Down

0 comments on commit 661f23d

Please sign in to comment.