+(defun macroexp--funcall-and-return (when-compiled when-interpreted form)
+ ;; FIXME: ¡¡Major Ugly Hack!! To determine whether the output of this
+ ;; macro-expansion will be processed by the byte-compiler, we check
+ ;; circumstantial evidence.
+ (if (member '(declare-function . byte-compile-macroexpand-declare-function)
+ macroexpand-all-environment)
+ `(progn
+ (macroexp--funcall-if-compiled ',when-compiled)
+ ,form)
+ (funcall when-interpreted)
+ form))
+
+(defun macroexp--warn-and-return (msg form)
+ (macroexp--funcall-and-return
+ (lambda () (byte-compile-log-warning msg t))
+ (lambda () (message "%s" msg))
+ form))