DR1579,
If the bbl of the shotgun is greater than 18" and the rifle bbl is greater than 16", you can bolt, glue, staple, nail, solder, weld, or tape them together until your heart is content, and it'd all be legal.
It's when you start shortening the barrels that it gets illegal in some states, and HIGHLY regulated in the others.
The Federal law states that if a shotgun has a stock, even if it's the stock of your M4, and a bbl shorter than 18", it is a short-bbl shotgun, and you must pay a $200 tax to manufacture it or to transfer ownership of it.
If you attach a stock to a pistol, it would become a short-barreled rifle, subject to the same taxation standards.
The same law states that if the shotgun has NEVER had a stock attached to it, you may register it as an AOW, or Any Other Weapon, by paying a $200 manufacturing tax. Any subsequent transfers of ownership would require a $5 transfer tax.
If you were to attach a vertical forward grip to a pistol, it would become an AOW, subject to the same taxation standards as an AOW shotgun.
In order to manufacture either of those types of weapons, you have to file the appropriate tax paperwork, namely an ATF Form 1, which is in effect, a tax return. In order to transfer either type, you have to file an ATF Form 4, which is, again, a type of tax return.