I wouldn't use WD40.
While gun oil can be expensive, I have heard that using a synthetic motor oil is just as good - if not better - and the quart will last you a lifetime.
As soon as my over-priced bottle of gun oil is used up, I plan on picking up a quart of Mobil 1 for use on my pistols.
WD40 is a very thin penetrating oil. While it is a lubricant, I would prefer a thicker lube.
WD40 would probably make a fine solvent of cleaning your guns, but I don't think it is sufficient for lubrication also.