Contrary to some rumours, it is perfectly acceptable to practise most popular religions in China. There are five official religions in China and all are represented in Shanghai: Buddhism, Taoism, Catholicism, Protestantism and Islam. Although Judaism is not officially recognised, Shanghai hosts a small but active Jewish community.
There are controls, however; the China-based Catholic Patriotic Association, rather than the Pope, is the ultimate authority over Shanghai's 140,000 Chinese Catholics, while local Protestants look to the Three Self-Patriotic Movement. Practising religion in licenced churches and in the privacy of your home is fine, but avoid proselytising in public – the government disapproves of this behaviour and it could be interpreted as disturbing the peaceful order. In some churches with English services, only foreign passport holders are allowed to attend. Also, avoid spending too much time professing your religion to Chinese colleagues, as it might make them uncomfortable.