As this Cathedral is the center of Catholic religion in Spain, I would refer to their stated dress code:
“Sagrada Familia Dress Code- Men
Men are allowed to wear T-shirts and shirts that do not have any offensive/distracting designs and promotional content.
Trousers or jeans that are full length can be worn. Shorts that are below the knee level can also be worn.
Sleeveless tank tops, vests and hats are not allowed.
No swimwear can be worn.”
And even though you didn’t ask, this is what they require for women:
Sagrada Familia Dress Code- Women
Women can wear blouses and tops with sleeves that completely cover the shoulders.
Dresses and tops that are backless or have a deep neckline are not allowed.
Trousers or skirts that come below knee level are allowed. (Please note they say below knee)
No hats or swimwear.