A typical fix and implementation of an ERC20 token is to rename the
public variable to
totalSupply (no underscore) and remove the function
totalSupply as it would then be auto-generated by Solidity.
Explanation of shadowing error message
function totalSupply() constant returns (uint256 totalSupply) indicates to the compiler that the return value will be variable
totalSupply (without underscore).
But the function is returning the value of another variable (looks the same but it's different since it has an underscore). So the compiler error is because the
totalSupply variable is being overridden / shadowed by another variable.
As @benjaminion explained, do not name the return value and just use:
function totalSupply() constant returns (uint256)
There is now no variable to shadow.