Fixes regression where the qualifier was ignored in an alias definition
if parentheses were not present.
gcc/d/ChangeLog:
* dmd/dsymbolsem.c (aliasInstanceSemantic): Merge storage class of old
alias into new symbol.
gcc/testsuite/ChangeLog:
* gdc.test/compilable/test21898.d: New test.
(cherry picked from commit
a30ee3aa8210f14fa3b4ee84fd3974c6b6a93047)
TemplateTypeParameter *ttp = (*tempdecl->parameters)[0]->isTemplateTypeParameter();
Type *ta = isType(tempinst->tdtypes[0]);
- Declaration *d = new AliasDeclaration(tempinst->loc, ttp->ident, ta->addMod(tempdecl->onemember->isAliasDeclaration()->type->mod));
- d->storage_class |= STCtemplateparameter;
+ AliasDeclaration *ad = tempdecl->onemember->isAliasDeclaration();
+
+ // Note: qualifiers can be in both 'ad.type.mod' and 'ad.storage_class'
+ Declaration *d = new AliasDeclaration(tempinst->loc, ttp->ident, ta->addMod(ad->type->mod));
+ d->storage_class |= STCtemplateparameter | ad->storage_class;
dsymbolSemantic(d, sc);
paramscope->pop();
--- /dev/null
+// https://issues.dlang.org/show_bug.cgi?id=21898
+
+alias Works(T) = immutable(T);
+alias Fails(T) = immutable T;
+
+static assert(is(Works!int == immutable int));
+static assert(is(Fails!int == immutable int));