Skip to content

Commit

Permalink
-v2: warn about const storage class
Browse files Browse the repository at this point in the history
As const is qualifier in D2 there is no striaghtforward
replacement for this D1 pattern. Most simple approach is to make
those variables mutable for transitional period and re-qualify
later on case by case basis.
  • Loading branch information
Mihails Strasuns committed Oct 9, 2014
1 parent d82522f commit f6508c9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/declaration.c
Expand Up @@ -779,6 +779,16 @@ void VarDeclaration::semantic(Scope *sc)
}

storage_class |= sc->stc;

if (global.params.Dversion >= 3)
{
if (storage_class & STCconst && !init)
{
warning(loc, "There is no const storage class in D2, make variable '%s'' non-const",
toChars());
}
}

if (storage_class & STCextern && init)
error("extern symbols cannot have initializers");

Expand Down

0 comments on commit f6508c9

Please sign in to comment.