In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/b289a0bd3e66981f9f724fb37f0f1aa6c8931ba0?hp=6b2c7479d6d33249c2385d8a36d8ee9e61e1a519>
- Log ----------------------------------------------------------------- commit b289a0bd3e66981f9f724fb37f0f1aa6c8931ba0 Author: Andy Lester <[email protected]> Date: Tue Nov 22 06:17:45 2016 -0700 Make (P)ure funcs in embed.fnc imply (R)eturn must be checked embed.fnc defines that a pure function is one that has no effects other than its return value. Therefore, calling such a function without using the return value must be an error. This patch makes a "P" "pure function" flag also imply the "R" "return value must be checked" flag. ----------------------------------------------------------------------- Summary of changes: embed.fnc | 4 ++-- proto.h | 22 ++++++++++++++++++++++ regen/embed.pl | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/embed.fnc b/embed.fnc index 9d40940..0c281cb 100644 --- a/embed.fnc +++ b/embed.fnc @@ -116,7 +116,7 @@ : : embed.h: suppress "#define foo Perl_foo" : -: P Pure function: no effects except the return value; +: P Pure function: Also implies "R". No effects except the return value; : return value depends only on params and/or globals: : : proto.h: add __attribute__pure__ @@ -126,7 +126,7 @@ : proto.h: function is declared as Perl_foo rather than foo : embed.h: "#define foo Perl_foo" entries added : -: R Return value must not be ignored (also implied by 'a' flag): +: R Return value must not be ignored (also implied by 'a' and 'P' flags): : : proto.h: add __attribute__warn_unused_result__ : diff --git a/proto.h b/proto.h index 0b10c0a..839bfdd 100644 --- a/proto.h +++ b/proto.h @@ -592,6 +592,7 @@ PERL_CALLCONV void Perl_custom_op_register(pTHX_ Perl_ppaddr_t ppaddr, const XOP #define PERL_ARGS_ASSERT_CUSTOM_OP_REGISTER \ assert(ppaddr); assert(xop) /* PERL_CALLCONV const XOP * Perl_custom_op_xop(pTHX_ const OP *o) + __attribute__warn_unused_result__ __attribute__pure__; */ PERL_CALLCONV void Perl_cv_ckproto_len_flags(pTHX_ const CV* cv, const GV* gv, const char* p, const STRLEN len, const U32 flags); @@ -869,16 +870,19 @@ PERL_CALLCONV char* Perl_find_script(pTHX_ const char *scriptname, bool dosearch #define PERL_ARGS_ASSERT_FIND_SCRIPT \ assert(scriptname) PERL_CALLCONV I32 Perl_foldEQ(const char* a, const char* b, I32 len) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_FOLDEQ \ assert(a); assert(b) PERL_CALLCONV I32 Perl_foldEQ_latin1(const char* a, const char* b, I32 len) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_FOLDEQ_LATIN1 \ assert(a); assert(b) PERL_CALLCONV I32 Perl_foldEQ_locale(const char* a, const char* b, I32 len) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_FOLDEQ_LOCALE \ assert(a); assert(b) @@ -1329,6 +1333,7 @@ PERL_CALLCONV bool Perl_isIDFIRST_lazy(pTHX_ const char* p) __attribute__pure__; */ PERL_STATIC_INLINE bool S_is_c9strict_utf8_string(const U8 *s, const STRLEN len) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_IS_C9STRICT_UTF8_STRING \ assert(s) @@ -1345,6 +1350,7 @@ PERL_CALLCONV I32 Perl_is_lvalue_sub(pTHX) __attribute__warn_unused_result__; PERL_STATIC_INLINE bool S_is_strict_utf8_string(const U8 *s, const STRLEN len) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_IS_STRICT_UTF8_STRING \ assert(s) @@ -1633,11 +1639,13 @@ PERL_CALLCONV bool Perl_is_utf8_space(pTHX_ const U8 *p) assert(p) PERL_STATIC_INLINE bool Perl_is_utf8_string(const U8 *s, const STRLEN len) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_IS_UTF8_STRING \ assert(s) PERL_STATIC_INLINE bool S_is_utf8_string_flags(const U8 *s, const STRLEN len, const U32 flags) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_IS_UTF8_STRING_FLAGS \ assert(s) @@ -1661,9 +1669,11 @@ PERL_CALLCONV bool Perl_is_utf8_upper(pTHX_ const U8 *p) assert(p) /* PERL_CALLCONV bool is_utf8_valid_partial_char(const U8 * const s, const U8 * const e) + __attribute__warn_unused_result__ __attribute__pure__; */ PERL_STATIC_INLINE bool S_is_utf8_valid_partial_char_flags(const U8 * const s, const U8 * const e, const U32 flags) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_IS_UTF8_VALID_PARTIAL_CHAR_FLAGS \ assert(s); assert(e) @@ -1694,6 +1704,7 @@ PERL_CALLCONV OP* Perl_jmaybe(pTHX_ OP *o); #define PERL_ARGS_ASSERT_JMAYBE \ assert(o) PERL_CALLCONV I32 Perl_keyword(pTHX_ const char *name, I32 len, bool all_keywords) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_KEYWORD \ assert(name) @@ -2637,6 +2648,7 @@ PERL_CALLCONV void Perl_require_pv(pTHX_ const char* pv); #define PERL_ARGS_ASSERT_REQUIRE_PV \ assert(pv) PERL_CALLCONV char* Perl_rninstr(const char* big, const char* bigend, const char* little, const char* lend) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_RNINSTR \ assert(big); assert(bigend); assert(little); assert(lend) @@ -3088,6 +3100,7 @@ PERL_CALLCONV void Perl_sv_free2(pTHX_ SV *const sv, const U32 refcnt); assert(sv) PERL_CALLCONV void Perl_sv_free_arenas(pTHX); PERL_CALLCONV SV* Perl_sv_get_backrefs(SV *const sv) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_SV_GET_BACKREFS \ assert(sv) @@ -3705,6 +3718,7 @@ STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *const sv); #endif #if !(defined(HAS_MEMMEM)) PERL_CALLCONV char* Perl_ninstr(const char* big, const char* bigend, const char* little, const char* lend) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_NINSTR \ assert(big); assert(bigend); assert(little); assert(lend) @@ -3728,6 +3742,7 @@ PERL_CALLCONV void* Perl_my_cxt_init(pTHX_ int *index, size_t size); #endif #if !(defined(WIN32)) /* PERL_CALLCONV char* my_setlocale(pTHX_ int category, const char* locale) + __attribute__warn_unused_result__ __attribute__pure__; */ #endif @@ -3750,6 +3765,7 @@ PERL_CALLCONV char* Perl_getenv_len(pTHX_ const char *env_elem, unsigned long *l #endif #if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP) PERL_CALLCONV int Perl_my_memcmp(const void* vs1, const void* vs2, size_t len) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_MY_MEMCMP \ assert(vs1); assert(vs2) @@ -3781,6 +3797,7 @@ PERL_CALLCONV I32 Perl_same_dirent(pTHX_ const char* a, const char* b); #endif #if !defined(HAS_SIGNBIT) PERL_CALLCONV int Perl_signbit(NV f) + __attribute__warn_unused_result__ __attribute__pure__; #endif @@ -4088,6 +4105,7 @@ PERL_CALLCONV void Perl_dump_sv_child(pTHX_ SV *sv); #endif #if defined(HAS_MEMMEM) PERL_CALLCONV char* Perl_ninstr(const char* big, const char* bigend, const char* little, const char* lend) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_NINSTR \ assert(big); assert(bigend); assert(little); assert(lend) @@ -4912,6 +4930,7 @@ PERL_STATIC_INLINE void S_alloc_maybe_populate_EXACT(pTHX_ RExC_state_t *pRExC_s #define PERL_ARGS_ASSERT_ALLOC_MAYBE_POPULATE_EXACT \ assert(pRExC_state); assert(node); assert(flagp) STATIC const char * S_cntrl_to_mnemonic(const U8 c) + __attribute__warn_unused_result__ __attribute__pure__; PERL_STATIC_INLINE U8 S_compute_EXACTish(RExC_state_t *pRExC_state); @@ -4921,6 +4940,7 @@ STATIC regnode * S_construct_ahocorasick_from_trie(pTHX_ RExC_state_t *pRExC_sta #define PERL_ARGS_ASSERT_CONSTRUCT_AHOCORASICK_FROM_TRIE \ assert(pRExC_state); assert(source) STATIC int S_edit_distance(const UV *src, const UV *tgt, const STRLEN x, const STRLEN y, const SSize_t maxDistance) + __attribute__warn_unused_result__ __attribute__pure__; #define PERL_ARGS_ASSERT_EDIT_DISTANCE \ assert(src); assert(tgt) @@ -5033,6 +5053,7 @@ STATIC regnode* S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 dept #define PERL_ARGS_ASSERT_REGCLASS \ assert(pRExC_state); assert(flagp) STATIC unsigned int S_regex_set_precedence(const U8 my_operator) + __attribute__warn_unused_result__ __attribute__pure__; STATIC void S_reginsert(pTHX_ RExC_state_t *pRExC_state, U8 op, regnode *opnd, U32 depth); @@ -5918,6 +5939,7 @@ PERL_CALLCONV const char* Perl_quadmath_format_single(const char* 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_NO_RET void win32_croak_not_implemented(const char * fname) diff --git a/regen/embed.pl b/regen/embed.pl index 19256eb..f1b7449 100755 --- a/regen/embed.pl +++ b/regen/embed.pl @@ -85,7 +85,7 @@ my ($embed, $core, $ext, $api) = setup_embed(); my $binarycompat = ( $flags =~ /b/ ); my $commented_out = ( ! $binarycompat && $flags =~ /m/ ); my $is_malloc = ( $flags =~ /a/ ); - my $can_ignore = ( $flags !~ /R/ ) && !$is_malloc; + my $can_ignore = ( $flags !~ /R/ ) && ( $flags !~ /P/ ) && !$is_malloc; my @names_of_nn; my $func; -- Perl5 Master Repository
