In Matthew 7:21-23, Jesus was refering to those who think they can get to heaven by just doing good works, or those that worship other gods. They will claim to have followed Jesus, when in fact they did not. That's what I think, anyway.
Jesus is simply teaching that some people pretend to be Christians when they actually are not.
One way they pretend is to do good works (charity). God is not fooled. But we can be. At least, if someone is running around pretending to be a Christian by loud charitable deeds, he is not in a position to activily critize the Lord too soon.