Preserve source position of macro calls in macro expansions
This allows the byte compiler to give correct positions, those
of the invoking forms, when an error or warning is caused by
the innards of the invoked macros.
This fixes bug#73725 and bug#73746.
* lisp/emacs-lisp/macroexp.el (macroexp--posify-form-1)
(macroexp--posify-form): New functions.
(macroexp-preserve-posification): New macro.
(macroexp--compiler-macro, macroexp-macroexpand): Use the new
macro to preserve a calling form's position.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-form): Use the new
macro to preserve source positions.
* test/lisp/emacs-lisp/bytecomp-resources/bad-error-position.el
* test/lisp/emacs-lisp/bytecomp-resources/bad-error-position-2.el:
New test files.
* test/lisp/emacs-lisp/bytecomp-tests.el: Two new tests using
the new test files.
(cherry picked from commit
c44903b0118357336cca964bd210835ca4881e87)