mirror of
https://github.com/dlang/dmd.git
synced 2025-04-28 22:20:37 +03:00
Merge pull request #4316 from 9rnsr/fix13860
Issue 13860 - template required forward reference for typeof(member)
This commit is contained in:
commit
661f23ddde
5 changed files with 34 additions and 9 deletions
|
@ -864,13 +864,11 @@ void VarDeclaration::semantic(Scope *sc)
|
||||||
if (sc->func->setUnsafe())
|
if (sc->func->setUnsafe())
|
||||||
error("__gshared not allowed in safe functions; use shared");
|
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");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
27
test/compilable/fwdref13860.d
Normal file
27
test/compilable/fwdref13860.d
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
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(15): Error: type MyUDC has no value
|
||||||
fail_compilation/ice12350.d(30): Error: template instance ice12350.testAttrs!(MyStruct) error instantiating
|
fail_compilation/ice12350.d(30): Error: template instance ice12350.testAttrs!(MyStruct) error instantiating
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
enum MyUDC;
|
enum MyUDC;
|
||||||
|
|
||||||
struct MyStruct
|
struct MyStruct
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
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
|
fail_compilation/ice12362.d(12): Error: cannot interpret foo at compile time
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum foo;
|
enum foo;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
enum bar = foo;
|
enum bar = foo;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
TEST_OUTPUT:
|
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
|
fail_compilation/ice13225.d(13): Error: undefined identifier undefined
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mixin template M(T) {}
|
mixin template M(T) {}
|
||||||
|
|
||||||
struct S
|
struct S
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue