This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
embed.fnc: Remove inappropriate pure attributes
authorKarl Williamson <khw@cpan.org>
Tue, 22 Nov 2016 18:30:28 +0000 (11:30 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 22 Nov 2016 18:38:12 +0000 (11:38 -0700)
In looking at the diffs from f6e4c377437f9b2ded79fb55f66983a6d4f761f9,
just committed, I realized that some of the functions marked pure,
really have side effects, if only initialization if not called
previously.  Still, the compiler could optimize things so it is wrong.
I then did a manual audit of embed.fnc, and removed the pure attribute
of the functions that I found that have some potential side effects.

embed.fnc
proto.h

index 0c281cb..4743aed 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -691,28 +691,28 @@ XopR      |I32    |was_lvalue_sub
 #ifndef PERL_NO_INLINE_FUNCTIONS
 ApMRnP |STRLEN |_is_utf8_char_helper|NN const U8 * const s|NN const U8 * e|const U32 flags
 #endif
-ADMpPR |U32    |to_uni_upper_lc|U32 c
-ADMpPR |U32    |to_uni_title_lc|U32 c
-ADMpPR |U32    |to_uni_lower_lc|U32 c
-ADMpPR |bool   |is_uni_alnum   |UV c
-ADMpPR |bool   |is_uni_alnumc  |UV c
-ADMpPR |bool   |is_uni_idfirst |UV c
-ADMpPR |bool   |is_uni_alpha   |UV c
+ADMp |U32    |to_uni_upper_lc|U32 c
+ADMp |U32    |to_uni_title_lc|U32 c
+ADMp |U32    |to_uni_lower_lc|U32 c
+ADMp |bool   |is_uni_alnum   |UV c
+ADMp |bool   |is_uni_alnumc  |UV c
+ADMp |bool   |is_uni_idfirst |UV c
+ADMp |bool   |is_uni_alpha   |UV c
 ADMpPR |bool   |is_uni_ascii   |UV c
 ADMpPR |bool   |is_uni_blank   |UV c
 ADMpPR |bool   |is_uni_space   |UV c
 ADMpPR |bool   |is_uni_cntrl   |UV c
-ADMpPR |bool   |is_uni_graph   |UV c
-ADMpPR |bool   |is_uni_digit   |UV c
-ADMpPR |bool   |is_uni_upper   |UV c
-ADMpPR |bool   |is_uni_lower   |UV c
-ADMpPR |bool   |is_uni_print   |UV c
-ADMpPR |bool   |is_uni_punct   |UV c
+ADMp |bool   |is_uni_graph   |UV c
+ADMp |bool   |is_uni_digit   |UV c
+ADMp |bool   |is_uni_upper   |UV c
+ADMp |bool   |is_uni_lower   |UV c
+ADMp |bool   |is_uni_print   |UV c
+ADMp |bool   |is_uni_punct   |UV c
 ADMpPR |bool   |is_uni_xdigit  |UV c
 AMp    |UV     |to_uni_upper   |UV c|NN U8 *p|NN STRLEN *lenp
 AMp    |UV     |to_uni_title   |UV c|NN U8 *p|NN STRLEN *lenp
-ADMpPR |bool   |isIDFIRST_lazy |NN const char* p
-ADMpPR |bool   |isALNUM_lazy   |NN const char* p
+ADMp |bool   |isIDFIRST_lazy |NN const char* p
+ADMp |bool   |isALNUM_lazy   |NN const char* p
 #ifdef PERL_IN_UTF8_C
 snR    |U8     |to_lower_latin1|const U8 c|NULLOK U8 *p|NULLOK STRLEN *lenp
 inPR   |bool   |is_utf8_cp_above_31_bits|NN const U8 * const s|NN const U8 * const e
@@ -726,22 +726,22 @@ p |UV     |_to_upper_title_latin1|const U8 c|NN U8 *p|NN STRLEN *lenp|const char S_o
 AMp    |UV     |to_uni_lower   |UV c|NN U8 *p|NN STRLEN *lenp
 AMmp   |UV     |to_uni_fold    |UV c|NN U8 *p|NN STRLEN *lenp
 AMp    |UV     |_to_uni_fold_flags|UV c|NN U8 *p|NN STRLEN *lenp|U8 flags
-ADMpPR |bool   |is_uni_alnum_lc|UV c
-ADMpPR |bool   |is_uni_alnumc_lc|UV c
-ADMpPR |bool   |is_uni_idfirst_lc|UV c
+ADMp |bool   |is_uni_alnum_lc|UV c
+ADMp |bool   |is_uni_alnumc_lc|UV c
+ADMp |bool   |is_uni_idfirst_lc|UV c
 AMpR   |bool   |_is_uni_perl_idcont|UV c
 AMpR   |bool   |_is_uni_perl_idstart|UV c
-ADMpPR |bool   |is_uni_alpha_lc|UV c
+ADMp |bool   |is_uni_alpha_lc|UV c
 ADMpPR |bool   |is_uni_ascii_lc|UV c
 ADMpPR |bool   |is_uni_space_lc|UV c
 ADMpPR |bool   |is_uni_blank_lc|UV c
 ADMpPR |bool   |is_uni_cntrl_lc|UV c
-ADMpPR |bool   |is_uni_graph_lc|UV c
-ADMpPR |bool   |is_uni_digit_lc|UV c
-ADMpPR |bool   |is_uni_upper_lc|UV c
-ADMpPR |bool   |is_uni_lower_lc|UV c
-ADMpPR |bool   |is_uni_print_lc|UV c
-ADMpPR |bool   |is_uni_punct_lc|UV c
+ADMp |bool   |is_uni_graph_lc|UV c
+ADMp |bool   |is_uni_digit_lc|UV c
+ADMp |bool   |is_uni_upper_lc|UV c
+ADMp |bool   |is_uni_lower_lc|UV c
+ADMp |bool   |is_uni_print_lc|UV c
+ADMp |bool   |is_uni_punct_lc|UV c
 ADMpPR |bool   |is_uni_xdigit_lc|UV c
 AnidRP |bool   |is_utf8_invariant_string|NN const U8* const s|STRLEN const len
 AmnpdRP        |bool   |is_ascii_string|NN const U8* const s|const STRLEN len
@@ -1210,9 +1210,9 @@ ApdO      |HV*    |get_hv         |NN const char *name|I32 flags
 ApdO   |CV*    |get_cv         |NN const char* name|I32 flags
 Apd    |CV*    |get_cvn_flags  |NN const char* name|STRLEN len|I32 flags
 #ifdef WIN32
-ApPM   |char*  |my_setlocale   |int category|NULLOK const char* locale
+Ap   |char*  |my_setlocale   |int category|NULLOK const char* locale
 #else
-AmPM   |char*  |my_setlocale   |int category|NULLOK const char* locale
+Am   |char*  |my_setlocale   |int category|NULLOK const char* locale
 #endif
 ApOM   |int    |init_i18nl10n  |int printwarn
 ApOM   |int    |init_i18nl14n  |int printwarn
@@ -2660,7 +2660,7 @@ s |void   |print_collxfrm_input_and_return                \
     && (defined(PERL_IN_LOCALE_C) || defined (PERL_EXT_POSIX))
 ApM    |bool   |_is_cur_LC_category_utf8|int category
 #      ifdef DEBUGGING
-AMnPpR |char * |_setlocale_debug_string|const int category                 \
+AMnpR  |char * |_setlocale_debug_string|const int category                 \
                                        |NULLOK const char* const locale    \
                                        |NULLOK const char* const retval
 #      endif
diff --git a/proto.h b/proto.h
index 839bfdd..5ff6bfe 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -1316,15 +1316,13 @@ PERL_CALLCONV bool      Perl_io_close(pTHX_ IO* io, GV *gv, bool not_implicit, bool w
        assert(io)
 PERL_CALLCONV bool     Perl_isALNUM_lazy(pTHX_ const char* p)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_ISALNUM_LAZY  \
        assert(p)
 
 PERL_CALLCONV bool     Perl_isIDFIRST_lazy(pTHX_ const char* p)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 #define PERL_ARGS_ASSERT_ISIDFIRST_LAZY        \
        assert(p)
 
@@ -1361,33 +1359,27 @@ PERL_STATIC_INLINE bool S_is_strict_utf8_string_loclen(const U8 *s, const STRLEN
        assert(s)
 PERL_CALLCONV bool     Perl_is_uni_alnum(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_alnum_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_alnumc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_alnumc_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_alpha(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_alpha_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_ascii(pTHX_ UV c)
                        __attribute__deprecated__
@@ -1421,63 +1413,51 @@ PERL_CALLCONV bool      Perl_is_uni_cntrl_lc(pTHX_ UV c)
 
 PERL_CALLCONV bool     Perl_is_uni_digit(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_digit_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_graph(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_graph_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_idfirst(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_idfirst_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_lower(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_lower_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_print(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_print_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_punct(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_punct_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_space(pTHX_ UV c)
                        __attribute__deprecated__
@@ -1491,13 +1471,11 @@ PERL_CALLCONV bool      Perl_is_uni_space_lc(pTHX_ UV c)
 
 PERL_CALLCONV bool     Perl_is_uni_upper(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_upper_lc(pTHX_ UV c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV bool     Perl_is_uni_xdigit(pTHX_ UV c)
                        __attribute__deprecated__
@@ -3450,24 +3428,21 @@ PERL_CALLCONV UV        Perl_to_uni_lower(pTHX_ UV c, U8 *p, STRLEN *lenp);
        assert(p); assert(lenp)
 PERL_CALLCONV U32      Perl_to_uni_lower_lc(pTHX_ U32 c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV UV       Perl_to_uni_title(pTHX_ UV c, U8 *p, STRLEN *lenp);
 #define PERL_ARGS_ASSERT_TO_UNI_TITLE  \
        assert(p); assert(lenp)
 PERL_CALLCONV U32      Perl_to_uni_title_lc(pTHX_ U32 c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV UV       Perl_to_uni_upper(pTHX_ UV c, U8 *p, STRLEN *lenp);
 #define PERL_ARGS_ASSERT_TO_UNI_UPPER  \
        assert(p); assert(lenp)
 PERL_CALLCONV U32      Perl_to_uni_upper_lc(pTHX_ U32 c)
                        __attribute__deprecated__
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 PERL_CALLCONV UV       Perl_to_utf8_case(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, const char *normal, const char *special)
                        __attribute__deprecated__;
@@ -3741,10 +3716,7 @@ PERL_CALLCONV void*      Perl_my_cxt_init(pTHX_ int *index, size_t size);
 #  endif
 #endif
 #if !(defined(WIN32))
-/* PERL_CALLCONV char* my_setlocale(pTHX_ int category, const char* locale)
-                       __attribute__warn_unused_result__
-                       __attribute__pure__; */
-
+/* PERL_CALLCONV char* my_setlocale(pTHX_ int category, const char* locale); */
 #endif
 #if !(defined(_MSC_VER))
 PERL_CALLCONV_NO_RET int       Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg)
@@ -4081,8 +4053,7 @@ STATIC int        S_tokereport(pTHX_ I32 rv, const YYSTYPE* lvalp);
 #  endif
 #  if defined(USE_LOCALE)     && (defined(PERL_IN_LOCALE_C) || defined (PERL_EXT_POSIX))
 PERL_CALLCONV char *   Perl__setlocale_debug_string(const int category, const char* const locale, const char* const retval)
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
+                       __attribute__warn_unused_result__;
 
 #  endif
 #  if defined(USE_LOCALE) && defined(PERL_IN_LOCALE_C)
@@ -5938,10 +5909,7 @@ PERL_CALLCONV const char*        Perl_quadmath_format_single(const char* format);
        assert(format)
 #endif
 #if defined(WIN32)
-PERL_CALLCONV char*    Perl_my_setlocale(pTHX_ int category, const char* locale)
-                       __attribute__warn_unused_result__
-                       __attribute__pure__;
-
+PERL_CALLCONV char*    Perl_my_setlocale(pTHX_ int category, const char* locale);
 PERL_CALLCONV_NO_RET void      win32_croak_not_implemented(const char * fname)
                        __attribute__noreturn__;
 #define PERL_ARGS_ASSERT_WIN32_CROAK_NOT_IMPLEMENTED   \