diff --git a/src/declaration.c b/src/declaration.c index b1292ec6daf4..9dbd57c14c23 100644 --- a/src/declaration.c +++ b/src/declaration.c @@ -441,6 +441,7 @@ Dsymbol *AliasDeclaration::syntaxCopy(Dsymbol *s) sa = new AliasDeclaration(loc, ident, type->syntaxCopy()); else sa = new AliasDeclaration(loc, ident, aliassym->syntaxCopy(NULL)); + sa->storage_class = storage_class; // Syntax copy for header file if (!htype) // Don't overwrite original diff --git a/test/runnable/declaration.d b/test/runnable/declaration.d index 8146fe754e13..7e1893788596 100644 --- a/test/runnable/declaration.d +++ b/test/runnable/declaration.d @@ -103,6 +103,29 @@ void test8410() Foo[5] a2 = { s: "hello" }; // error } +/***************************************************/ +// 8942 + +alias const int A8942_0; +static assert(is(A8942_0 == const int)); // passes + +void test8942() +{ + alias const int A8942_1; + static assert(is(A8942_1 == const int)); // passes + + static struct S { int i; } + foreach (Unused; typeof(S.tupleof)) + { + alias const(int) A8942_2; + static assert(is(A8942_2 == const int)); // also passes + + alias const int A8942_3; + static assert(is(A8942_3 == const int)); // fails + // Error: static assert (is(int == const(int))) is false + } +} + /***************************************************/ int main() @@ -112,6 +135,7 @@ int main() test8123(); test8147(); test8410(); + test8942(); printf("Success\n"); return 0;