fix C++ builds broken by cdc4a174060
authorDaniel Dragan <bulk88@hotmail.com>
Wed, 10 Oct 2012 21:23:27 +0000 (17:23 -0400)
committerKarl Williamson <public@khwilliamson.com>
Wed, 10 Oct 2012 23:09:05 +0000 (17:09 -0600)
In commit cdc4a174060 static noreturn function, on a C++ build, (specific
example, GCC ) got a post preprocessor prototype of
"extern "C" static void S_fn_doesnt_return(". GCC generates a compile error
if "extern "C"" and static used together. Plain C build were not affected.

This commit fixed the problem by creating 2 new static exclusive macros, so
extern "C" does not wind up on statics in a C++ build. The macros allow
enough flexibility so any compiler/platform that needs a noreturn
declaration specifier instead of a noreturn function attribute can have
one.

perl.h
proto.h
regen/embed.pl
win32/win32.h

diff --git a/perl.h b/perl.h
index bf96a8e..dfa0a4a 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5017,6 +5017,20 @@ struct tempsym; /* defined in pp_pack.c */
 #    define PERL_CALLCONV_NO_RET PERL_CALLCONV
 #endif
 
+/* PERL_STATIC_NO_RET is supposed to be equivalent to STATIC on builds that
+   dont have a noreturn as a declaration specifier
+*/
+#ifndef PERL_STATIC_NO_RET
+#  define PERL_STATIC_NO_RET STATIC
+#endif
+/* PERL_STATIC_NO_RET is supposed to be equivalent to PERL_STATIC_INLINE on
+   builds that dont have a noreturn as a declaration specifier
+*/
+#ifndef PERL_STATIC_INLINE_NO_RET
+#  define PERL_STATIC_INLINE_NO_RET PERL_STATIC_INLINE
+#endif
+
+
 #undef PERL_CKDEF
 #undef PERL_PPDEF
 #define PERL_CKDEF(s)  PERL_CALLCONV OP *s (pTHX_ OP *o);
diff --git a/proto.h b/proto.h
index 01d1e12..e290c47 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -5626,7 +5626,7 @@ STATIC void       S_hv_magic_check(HV *hv, bool *needs_copy, bool *needs_store)
 #define PERL_ARGS_ASSERT_HV_MAGIC_CHECK        \
        assert(hv); assert(needs_copy); assert(needs_store)
 
-PERL_CALLCONV_NO_RET STATIC void       S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg)
+PERL_STATIC_NO_RET void        S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg)
                        __attribute__noreturn__
                        __attribute__nonnull__(pTHX_2)
                        __attribute__nonnull__(pTHX_4);
@@ -5992,10 +5992,10 @@ STATIC SV*      S_mayberelocate(pTHX_ const char *const dir, STRLEN len, U32 flags)
 #define PERL_ARGS_ASSERT_MAYBERELOCATE \
        assert(dir)
 
-PERL_CALLCONV_NO_RET STATIC void       S_minus_v(pTHX)
+PERL_STATIC_NO_RET void        S_minus_v(pTHX)
                        __attribute__noreturn__;
 
-PERL_CALLCONV_NO_RET STATIC void       S_my_exit_jump(pTHX)
+PERL_STATIC_NO_RET void        S_my_exit_jump(pTHX)
                        __attribute__noreturn__;
 
 STATIC void    S_nuke_stacks(pTHX);
@@ -6006,10 +6006,10 @@ STATIC PerlIO * S_open_script(pTHX_ const char *scriptname, bool dosearch, bool
        assert(scriptname); assert(suidscript)
 
 STATIC void*   S_parse_body(pTHX_ char **env, XSINIT_t xsinit);
-PERL_CALLCONV_NO_RET STATIC void       S_run_body(pTHX_ I32 oldscope)
+PERL_STATIC_NO_RET void        S_run_body(pTHX_ I32 oldscope)
                        __attribute__noreturn__;
 
-PERL_CALLCONV_NO_RET STATIC void       S_usage(pTHX)
+PERL_STATIC_NO_RET void        S_usage(pTHX)
                        __attribute__noreturn__;
 
 #endif
@@ -6522,7 +6522,7 @@ STATIC char *     S_nextchar(pTHX_ struct RExC_state_t *pRExC_state)
 #define PERL_ARGS_ASSERT_NEXTCHAR      \
        assert(pRExC_state)
 
-PERL_CALLCONV_NO_RET STATIC void       S_re_croak2(pTHX_ const char* pat1, const char* pat2, ...)
+PERL_STATIC_NO_RET void        S_re_croak2(pTHX_ const char* pat1, const char* pat2, ...)
                        __attribute__noreturn__
                        __attribute__nonnull__(pTHX_1)
                        __attribute__nonnull__(pTHX_2);
@@ -7090,7 +7090,7 @@ STATIC I32        S_lop(pTHX_ I32 f, int x, char *s)
 #define PERL_ARGS_ASSERT_LOP   \
        assert(s)
 
-PERL_CALLCONV_NO_RET STATIC void       S_missingterm(pTHX_ char *s)
+PERL_STATIC_NO_RET void        S_missingterm(pTHX_ char *s)
                        __attribute__noreturn__;
 
 STATIC SV*     S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, STRLEN keylen, SV *sv, SV *pv, const char *type, STRLEN typelen)
@@ -7297,7 +7297,7 @@ STATIC SV *       S_with_queued_errors(pTHX_ SV *ex)
 #define PERL_ARGS_ASSERT_WITH_QUEUED_ERRORS    \
        assert(ex)
 
-PERL_CALLCONV_NO_RET STATIC char *     S_write_no_mem(pTHX)
+PERL_STATIC_NO_RET char *      S_write_no_mem(pTHX)
                        __attribute__noreturn__;
 
 #  if defined(PERL_MEM_LOG) && !defined(PERL_MEM_LOG_NOIMPL)
index a7419ba..1f5b749 100755 (executable)
@@ -85,13 +85,16 @@ my ($embed, $core, $ext, $api) = setup_embed();
        }
 
        if ($flags =~ /([si])/) {
-           my $type = ($1 eq 's') ? "STATIC" : "PERL_STATIC_INLINE";
+           my $type;
+           if ($never_returns) {
+               $type = $1 eq 's' ? "PERL_STATIC_NO_RET" : "PERL_STATIC_INLINE_NO_RET";
+           }
+           else {
+               $type = $1 eq 's' ? "STATIC" : "PERL_STATIC_INLINE";
+           }
            warn "$func: i and s flags are mutually exclusive"
                                            if $flags =~ /s/ && $flags =~ /i/;
            $retval = "$type $splint_flags$retval";
-           if ($never_returns) {
-               $retval = "PERL_CALLCONV_NO_RET $retval";
-           }
            $func = "S_$plain_func";
        }
        else {
index 489fbf4..59a3052 100644 (file)
 #  endif
 #endif
 
+#ifdef _MSC_VER
+#  define PERL_STATIC_NO_RET __declspec(noreturn) static
+#  define PERL_STATIC_INLINE_NO_RET __declspec(noreturn) PERL_STATIC_INLINE
+#endif
+
 #define  WIN32_LEAN_AND_MEAN
 #include <windows.h>