This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Mark several functions with __attribute__noreturn__
authorBrian Fraser <fraserbn@gmail.com>
Fri, 30 May 2014 23:19:27 +0000 (01:19 +0200)
committerBrian Fraser <fraserbn@gmail.com>
Thu, 12 Jun 2014 22:00:32 +0000 (00:00 +0200)
Namely, die_nocontext, die, die_sv, and screaminstr. They
all croak and never return, so let's mark them as non-returning.

embed.fnc
embed.h
proto.h
util.c

index 7574d3f..659c432 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -280,7 +280,12 @@ norx       |void   |win32_croak_not_implemented|NN const char * fname
 #endif
 #if defined(PERL_IMPLICIT_CONTEXT)
 Afnrp  |void   |croak_nocontext|NULLOK const char* pat|...
-Afnp   |OP*    |die_nocontext  |NULLOK const char* pat|...
+:removing noreturn to silence a warning
+#ifdef _MSC_VER
+Afnp   |OP*    |die_nocontext  |NULLOK const char* pat|...
+#else
+Afnrp  |OP*    |die_nocontext  |NULLOK const char* pat|...
+#endif
 Afnp   |void   |deb_nocontext  |NN const char* pat|...
 Afnp   |char*  |form_nocontext |NN const char* pat|...
 Anp    |void   |load_module_nocontext|U32 flags|NN SV* name|NULLOK SV* ver|...
@@ -337,8 +342,14 @@ Anp        |char*  |delimcpy       |NN char* to|NN const char* toend|NN const char* from \
                                |NN const char* fromend|int delim|NN I32* retlen
 : Used in op.c, perl.c
 pM     |void   |delete_eval_scope
-Apd    |OP*    |die_sv         |NN SV *baseex
-Afpd   |OP*    |die            |NULLOK const char* pat|...
+:removing noreturn to silence a warning
+#ifdef _MSC_VER
+Apd    |OP*    |die_sv         |NN SV *baseex
+Afpd   |OP*    |die            |NULLOK const char* pat|...
+#else
+Aprd    |OP*    |die_sv         |NN SV *baseex
+Afrpd   |OP*    |die            |NULLOK const char* pat|...
+#endif
 : Used in util.c
 pr     |void   |die_unwind     |NN SV* msv
 Ap     |void   |dounwind       |I32 cxix
@@ -1291,8 +1302,14 @@ Apd      |NV     |scan_hex       |NN const char* start|STRLEN len|NN STRLEN* retlen
 Ap     |char*  |scan_num       |NN const char* s|NN YYSTYPE *lvalp
 Apd    |NV     |scan_oct       |NN const char* start|STRLEN len|NN STRLEN* retlen
 AMpd   |OP*    |op_scope       |NULLOK OP* o
-Ap     |char*  |screaminstr    |NN SV *bigstr|NN SV *littlestr|I32 start_shift \
-                               |I32 end_shift|NN I32 *old_posp|I32 last
+:removing noreturn to silence a warning
+#ifdef _MSC_VER
+Ap      |char*  |screaminstr    |NN SV *bigstr|NN SV *littlestr|I32 start_shift \
+                                |I32 end_shift|NN I32 *old_posp|I32 last
+#else
+Apr     |char*  |screaminstr    |NN SV *bigstr|NN SV *littlestr|I32 start_shift \
+                                |I32 end_shift|NN I32 *old_posp|I32 last
+#endif
 : Only used by perl.c/miniperl.c, but defined in caretx.c
 px     |void   |set_caret_X
 Apd    |void   |setdefout      |NN GV* gv
diff --git a/embed.h b/embed.h
index 13504b1..6b0f834 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define debstackptrs()         Perl_debstackptrs(aTHX)
 #define delimcpy               Perl_delimcpy
 #define despatch_signals()     Perl_despatch_signals(aTHX)
-#ifndef PERL_IMPLICIT_CONTEXT
-#define die                    Perl_die
-#endif
-#define die_sv(a)              Perl_die_sv(aTHX_ a)
 #define do_binmode(a,b,c)      Perl_do_binmode(aTHX_ a,b,c)
 #define do_close(a,b)          Perl_do_close(aTHX_ a,b)
 #define do_gv_dump(a,b,c,d)    Perl_do_gv_dump(aTHX_ a,b,c,d)
 #define scan_oct(a,b,c)                Perl_scan_oct(aTHX_ a,b,c)
 #define scan_version(a,b,c)    Perl_scan_version(aTHX_ a,b,c)
 #define scan_vstring(a,b,c)    Perl_scan_vstring(aTHX_ a,b,c)
-#define screaminstr(a,b,c,d,e,f)       Perl_screaminstr(aTHX_ a,b,c,d,e,f)
 #define seed()                 Perl_seed(aTHX)
 #define set_context            Perl_set_context
 #define set_numeric_local()    Perl_set_numeric_local(aTHX)
 #if !(defined(PERL_MAD))
 #define newFORM(a,b,c)         Perl_newFORM(aTHX_ a,b,c)
 #endif
+#if !(defined(_MSC_VER))
+#ifndef PERL_IMPLICIT_CONTEXT
+#define die                    Perl_die
+#endif
+#define die_sv(a)              Perl_die_sv(aTHX_ a)
+#define screaminstr(a,b,c,d,e,f)       Perl_screaminstr(aTHX_ a,b,c,d,e,f)
+#  if defined(PERL_IMPLICIT_CONTEXT)
+#define die_nocontext          Perl_die_nocontext
+#  endif
+#endif
 #if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
 #define my_bzero               Perl_my_bzero
 #endif
 #if defined(PERL_IMPLICIT_CONTEXT)
 #define croak_nocontext                Perl_croak_nocontext
 #define deb_nocontext          Perl_deb_nocontext
-#define die_nocontext          Perl_die_nocontext
 #define form_nocontext         Perl_form_nocontext
 #define fprintf_nocontext      Perl_fprintf_nocontext
 #define load_module_nocontext  Perl_load_module_nocontext
 #define sv_setpvf_nocontext    Perl_sv_setpvf_nocontext
 #define warn_nocontext         Perl_warn_nocontext
 #define warner_nocontext       Perl_warner_nocontext
+#  if defined(_MSC_VER)
+#define die_nocontext          Perl_die_nocontext
+#  endif
 #endif
 #if defined(PERL_IN_REGCOMP_C) || defined(PERL_IN_PERL_C) || defined(PERL_IN_UTF8_C)
 #define _new_invlist_C_array(a)        Perl__new_invlist_C_array(aTHX_ a)
 #define do_spawn(a)            Perl_do_spawn(aTHX_ a)
 #define do_spawn_nowait(a)     Perl_do_spawn_nowait(aTHX_ a)
 #endif
+#if defined(_MSC_VER)
+#ifndef PERL_IMPLICIT_CONTEXT
+#define die                    Perl_die
+#endif
+#define die_sv(a)              Perl_die_sv(aTHX_ a)
+#define screaminstr(a,b,c,d,e,f)       Perl_screaminstr(aTHX_ a,b,c,d,e,f)
+#endif
 #if defined(PERL_CORE) || defined(PERL_EXT)
 #define av_reify(a)            Perl_av_reify(aTHX_ a)
 #define current_re_engine()    Perl_current_re_engine(aTHX)
diff --git a/proto.h b/proto.h
index 1c339e9..37ba5dd 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -873,14 +873,6 @@ PERL_CALLCONV char*        Perl_delimcpy(char* to, const char* toend, const char* from,
        assert(to); assert(toend); assert(from); assert(fromend); assert(retlen)
 
 PERL_CALLCONV void     Perl_despatch_signals(pTHX);
-PERL_CALLCONV OP*      Perl_die(pTHX_ const char* pat, ...)
-                       __attribute__format__null_ok__(__printf__,pTHX_1,pTHX_2);
-
-PERL_CALLCONV OP*      Perl_die_sv(pTHX_ SV *baseex)
-                       __attribute__nonnull__(pTHX_1);
-#define PERL_ARGS_ASSERT_DIE_SV        \
-       assert(baseex)
-
 PERL_CALLCONV_NO_RET void      Perl_die_unwind(pTHX_ SV* msv)
                        __attribute__noreturn__
                        __attribute__nonnull__(pTHX_1);
@@ -3855,13 +3847,6 @@ PERL_CALLCONV char*      Perl_scan_vstring(pTHX_ const char *s, const char *const e,
 #define PERL_ARGS_ASSERT_SCAN_VSTRING  \
        assert(s); assert(e); assert(sv)
 
-PERL_CALLCONV char*    Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift, I32 *old_posp, I32 last)
-                       __attribute__nonnull__(pTHX_1)
-                       __attribute__nonnull__(pTHX_2)
-                       __attribute__nonnull__(pTHX_5);
-#define PERL_ARGS_ASSERT_SCREAMINSTR   \
-       assert(bigstr); assert(littlestr); assert(old_posp)
-
 PERL_CALLCONV U32      Perl_seed(pTHX);
 PERL_CALLCONV void     Perl_set_caret_X(pTHX);
 PERL_CALLCONV void     Perl_set_context(void *t)
@@ -5133,6 +5118,16 @@ PERL_CALLCONV void       Perl_utilize(pTHX_ int aver, I32 floor, OP* version, OP* idop
 
 #endif
 #if !(defined(_MSC_VER))
+PERL_CALLCONV_NO_RET OP*       Perl_die(pTHX_ const char* pat, ...)
+                       __attribute__noreturn__
+                       __attribute__format__null_ok__(__printf__,pTHX_1,pTHX_2);
+
+PERL_CALLCONV_NO_RET OP*       Perl_die_sv(pTHX_ SV *baseex)
+                       __attribute__noreturn__
+                       __attribute__nonnull__(pTHX_1);
+#define PERL_ARGS_ASSERT_DIE_SV        \
+       assert(baseex)
+
 PERL_CALLCONV_NO_RET int       Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg)
                        __attribute__noreturn__
                        __attribute__nonnull__(pTHX_1)
@@ -5140,6 +5135,20 @@ PERL_CALLCONV_NO_RET int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg)
 #define PERL_ARGS_ASSERT_MAGIC_REGDATUM_SET    \
        assert(sv); assert(mg)
 
+PERL_CALLCONV_NO_RET char*     Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift, I32 *old_posp, I32 last)
+                       __attribute__noreturn__
+                       __attribute__nonnull__(pTHX_1)
+                       __attribute__nonnull__(pTHX_2)
+                       __attribute__nonnull__(pTHX_5);
+#define PERL_ARGS_ASSERT_SCREAMINSTR   \
+       assert(bigstr); assert(littlestr); assert(old_posp)
+
+#  if defined(PERL_IMPLICIT_CONTEXT)
+PERL_CALLCONV_NO_RET OP*       Perl_die_nocontext(const char* pat, ...)
+                       __attribute__noreturn__
+                       __attribute__format__null_ok__(__printf__,1,2);
+
+#  endif
 #endif
 #if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
 PERL_CALLCONV char*    Perl_my_bzero(char* loc, I32 len)
@@ -5629,9 +5638,6 @@ PERL_CALLCONV void        Perl_deb_nocontext(const char* pat, ...)
 #define PERL_ARGS_ASSERT_DEB_NOCONTEXT \
        assert(pat)
 
-PERL_CALLCONV OP*      Perl_die_nocontext(const char* pat, ...)
-                       __attribute__format__null_ok__(__printf__,1,2);
-
 PERL_CALLCONV char*    Perl_form_nocontext(const char* pat, ...)
                        __attribute__format__(__printf__,1,2)
                        __attribute__nonnull__(1);
@@ -5708,6 +5714,11 @@ PERL_CALLCONV void       Perl_warner_nocontext(U32 err, const char* pat, ...)
 #define PERL_ARGS_ASSERT_WARNER_NOCONTEXT      \
        assert(pat)
 
+#  if defined(_MSC_VER)
+PERL_CALLCONV OP*      Perl_die_nocontext(const char* pat, ...)
+                       __attribute__format__null_ok__(__printf__,1,2);
+
+#  endif
 #endif
 #if defined(PERL_IMPLICIT_SYS)
 PERL_CALLCONV PerlInterpreter* perl_alloc_using(struct IPerlMem *ipM, struct IPerlMem *ipMS, struct IPerlMem *ipMP, struct IPerlEnv *ipE, struct IPerlStdIO *ipStd, struct IPerlLIO *ipLIO, struct IPerlDir *ipD, struct IPerlSock *ipS, struct IPerlProc *ipP)
@@ -8177,12 +8188,27 @@ PERL_CALLCONV int       Perl_do_spawn_nowait(pTHX_ char* cmd)
 
 #endif
 #if defined(_MSC_VER)
+PERL_CALLCONV OP*      Perl_die(pTHX_ const char* pat, ...)
+                       __attribute__format__null_ok__(__printf__,pTHX_1,pTHX_2);
+
+PERL_CALLCONV OP*      Perl_die_sv(pTHX_ SV *baseex)
+                       __attribute__nonnull__(pTHX_1);
+#define PERL_ARGS_ASSERT_DIE_SV        \
+       assert(baseex)
+
 PERL_CALLCONV int      Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg)
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2);
 #define PERL_ARGS_ASSERT_MAGIC_REGDATUM_SET    \
        assert(sv); assert(mg)
 
+PERL_CALLCONV char*    Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift, I32 *old_posp, I32 last)
+                       __attribute__nonnull__(pTHX_1)
+                       __attribute__nonnull__(pTHX_2)
+                       __attribute__nonnull__(pTHX_5);
+#define PERL_ARGS_ASSERT_SCREAMINSTR   \
+       assert(bigstr); assert(littlestr); assert(old_posp)
+
 #endif
 #ifdef PERL_CORE
 #  include "pp_proto.h"
diff --git a/util.c b/util.c
index 0005b43..3fa7991 100644 (file)
--- a/util.c
+++ b/util.c
@@ -925,7 +925,7 @@ Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift
     /* This function must only ever be called on a scalar with study magic,
        but those do not happen any more. */
     Perl_croak(aTHX_ "panic: screaminstr");
-    return NULL;
+    NORETURN_FUNCTION_END;
 }
 
 /*
@@ -1568,7 +1568,7 @@ Perl_die_sv(pTHX_ SV *baseex)
     PERL_ARGS_ASSERT_DIE_SV;
     croak_sv(baseex);
     assert(0); /* NOTREACHED */
-    return NULL;
+    NORETURN_FUNCTION_END;
 }
 
 /*
@@ -1591,7 +1591,7 @@ Perl_die_nocontext(const char* pat, ...)
     vcroak(pat, &args);
     assert(0); /* NOTREACHED */
     va_end(args);
-    return NULL;
+    NORETURN_FUNCTION_END;
 }
 #endif /* PERL_IMPLICIT_CONTEXT */
 
@@ -1603,7 +1603,7 @@ Perl_die(pTHX_ const char* pat, ...)
     vcroak(pat, &args);
     assert(0); /* NOTREACHED */
     va_end(args);
-    return NULL;
+    NORETURN_FUNCTION_END;
 }
 
 /*