Abu Hurairah (May Allah be pleased with him) said: The Messenger of Allah (PBUH) said, "Almighty Allah says, `I am the One Who is most free from want of partners. He who does a thing for the sake of someone else beside Me, I discard him and his polytheism.."[Muslim].
"He who does a thing for the sake of someone else beside Me" here means to do something virtuous for mere show for worldly benefit, or to gain the reputation of being pious. "I discard him and his polytheism" means that "I nullify his good deeds and deprive him of the reward." In this Hadith any virtue done for the sake of mere show has been likened to Shirk to make its viciousness and harm obvious.
However, this is Ash-Shirk Al-Asghar, and those who commit it will not be forbidden access to Jannah. They will, after the punishment in Hell, ultimately enter Jannah. Whereas, those who are guilty of Ash-Shirk Al-Akbar and sheer Shirk will abide in Hell forever.