emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 552694a 1/2: Revert attempt to use 'noexcept' in


From: Paul Eggert
Subject: [Emacs-diffs] emacs-25 552694a 1/2: Revert attempt to use 'noexcept' in typedef
Date: Mon, 11 Jan 2016 05:46:41 +0000

branch: emacs-25
commit 552694a2653b4f9cde515139d01793a5a0e964b7
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Revert attempt to use 'noexcept' in typedef
    
    This use of 'noexcept' runs afoul of the C++11 standard.
    Problem reported by Philipp Stephani in:
    http://lists.gnu.org/archive/html/emacs-devel/2016-01/msg00706.html
    * src/emacs-module.c (emacs_finalizer_function):
    Move this typedef here ...
    * src/emacs-module.h: ... from here, and use only the C
    version of the typedef.  The typedef is now private since it
    is never used in the .h file now and anyway it seemed to be
    causing more confusion than it cured.
    (make_user_ptr, get_user_finalizer, set_user_finalizer):
    Open-code the type instead.
---
 src/emacs-module.c |    6 ++++++
 src/emacs-module.h |   19 ++++---------------
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/emacs-module.c b/src/emacs-module.c
index 2fec7e5..b5e044e 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -65,6 +65,12 @@ enum
         && INTPTR_MAX == EMACS_INT_MAX)
   };
 
+/* Function prototype for module user-pointer finalizers.  These
+   should not throw C++ exceptions, so emacs-module.h declares the
+   corresponding interfaces with EMACS_NOEXCEPT.  There is only C code
+   in this module, though, so this constraint is not enforced here.  */
+typedef void (*emacs_finalizer_function) (void *);
+
 
 /* Private runtime and environment members.  */
 
diff --git a/src/emacs-module.h b/src/emacs-module.h
index 3efea34..575966e 100644
--- a/src/emacs-module.h
+++ b/src/emacs-module.h
@@ -26,19 +26,8 @@ along with GNU Emacs.  If not, see 
<http://www.gnu.org/licenses/>.  */
 
 #if defined __cplusplus && __cplusplus >= 201103L
 # define EMACS_NOEXCEPT noexcept
-
-/* Function prototype for module user-pointer finalizers.
-
-   NOTE: C++11 15.4: An exception-specification shall not appear in a
-                     typedef declaration or alias-declaration.
-
-*/
-void emacs_dummy_finalizer_function (void *) noexcept;
-typedef decltype(emacs_dummy_finalizer_function) *emacs_finalizer_function;
-
 #else
 # define EMACS_NOEXCEPT
-typedef void (*emacs_finalizer_function) (void *);
 #endif
 
 #ifdef __cplusplus
@@ -184,17 +173,17 @@ struct emacs_env_25
 
   /* Embedded pointer type.  */
   emacs_value (*make_user_ptr) (emacs_env *env,
-                               emacs_finalizer_function fin,
+                               void (*fin) (void *) EMACS_NOEXCEPT,
                                void *ptr);
 
   void *(*get_user_ptr) (emacs_env *env, emacs_value uptr);
   void (*set_user_ptr) (emacs_env *env, emacs_value uptr, void *ptr);
 
-  emacs_finalizer_function (*get_user_finalizer) (emacs_env *env,
-                                                 emacs_value uptr);
+  void (*(*get_user_finalizer) (emacs_env *env, emacs_value uptr))
+    (void *) EMACS_NOEXCEPT;
   void (*set_user_finalizer) (emacs_env *env,
                              emacs_value uptr,
-                             emacs_finalizer_function fin);
+                             void (*fin) (void *) EMACS_NOEXCEPT);
 
   /* Vector functions.  */
   emacs_value (*vec_get) (emacs_env *env, emacs_value vec, ptrdiff_t i);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]