diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2022-01-22 16:49:37 +0000 |
---|---|---|
committer | Paul Evans <leonerd@leonerd.org.uk> | 2022-01-25 15:02:58 +0000 |
commit | 929db505d1c4d59500799cc32db9f6ebdebc95c0 (patch) | |
tree | 90914ec36ca5f2feb08fbc0caa5fce627c84a9c5 /builtin.c | |
parent | c6874a08f06d60ec8b3f9e21a538a38282910123 (diff) | |
download | perl-929db505d1c4d59500799cc32db9f6ebdebc95c0.tar.gz |
Warn about experimental builtins at runtime as well as compile time
For when the functions are called via reference or perl4-style &foo syntax.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -23,10 +23,20 @@ struct BuiltinFuncDescriptor { IV ckval; }; +#define warn_experimental_builtin(name, prefix) S_warn_experimental_builtin(aTHX_ name, prefix) +static void S_warn_experimental_builtin(pTHX_ const char *name, bool prefix) +{ + /* diag_listed_as: Built-in function '%s' is experimental */ + Perl_ck_warner_d(aTHX_ packWARN(WARN_EXPERIMENTAL__BUILTIN), + "Built-in function '%s%s' is experimental", + prefix ? "builtin::" : "", name); +} + XS(XS_builtin_true); XS(XS_builtin_true) { dXSARGS; + warn_experimental_builtin("true", true); if(items) croak_xs_usage(cv, ""); XSRETURN_YES; @@ -36,6 +46,7 @@ XS(XS_builtin_false); XS(XS_builtin_false) { dXSARGS; + warn_experimental_builtin("false", true); if(items) croak_xs_usage(cv, ""); XSRETURN_NO; @@ -50,9 +61,7 @@ static OP *ck_builtin_const(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) { const struct BuiltinFuncDescriptor *builtin = NUM2PTR(const struct BuiltinFuncDescriptor *, SvUV(ckobj)); - Perl_ck_warner_d(aTHX_ - packWARN(WARN_EXPERIMENTAL__BUILTIN), - "Built-in function '%s' is experimental", builtin->name); + warn_experimental_builtin(builtin->name, false); SV *prototype = newSVpvs(""); SAVEFREESV(prototype); @@ -81,6 +90,8 @@ XS(XS_builtin_func1_scalar) dXSARGS; dXSI32; + warn_experimental_builtin(PL_op_name[ix], true); + if(items != 1) croak_xs_usage(cv, "arg"); @@ -126,6 +137,8 @@ XS(XS_builtin_func1_void) dXSARGS; dXSI32; + warn_experimental_builtin(PL_op_name[ix], true); + if(items != 1) croak_xs_usage(cv, "arg"); @@ -149,9 +162,7 @@ static OP *ck_builtin_func1(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) { const struct BuiltinFuncDescriptor *builtin = NUM2PTR(const struct BuiltinFuncDescriptor *, SvUV(ckobj)); - Perl_ck_warner_d(aTHX_ - packWARN(WARN_EXPERIMENTAL__BUILTIN), - "Built-in function '%s' is experimental", builtin->name); + warn_experimental_builtin(builtin->name, false); SV *prototype = newSVpvs("$"); SAVEFREESV(prototype); |