Absolutely - in terms of the AA used for support though, it wasn't the 20mm or 40mm, but the large-calibre AA - the British doctrine was to have 40 degree (iirc, about that, I can look up - and it got higher later in the war) elevation on their main guns precisely so they could provide supporting AA fire above the capital ships of the fleet. There are some great photos from Operation Pedestal showing this in action. Many British ships were also fitted with barrage fire directors - the point of which was to provide a wall of heavy AA fire at a fixed point on the perimeter of the fleet (so it was an area-based approach) that enemy bombers had to fly through. The effective range of the 4in, 4.7in, 5in and 5.25in AA guns was measured in kilometres, and was well long enough to provide supporting AA fire. 40mm Bofors could provide some supporting fire to ships close by (2pdr AA less so, but still a bit), and 20mm's and lower effective range was so small that it was really only for own-ship defence).
Indeed, some nations (Brits and Japanese) designed their cruiser-calibre guns (and the Japanese, their BB-calibre guns!) to provide AA fire support that was applicable at the fleet level.
If you read the account of the attack on
Prince of Wales and
Repulse in
British Battleships of World War Two, you'll see clear reference to the large-calibre AA being used by both ships on attacks on either (so
PoW fired on aircraft attacking
Repulse, and vice versa), and it's all through accounts of Operation Pedestal. I don't have time to look up now (off to work), but if you still don't believe me (and don't feel like reading the Reports of Proceedings or similar yourself to get up to speed), reply again and I'll swing by this evening and take some photos from the books mentioned above and post in here