From: Niko Tyni Date: Tue, 14 Apr 2009 19:55:34 +0000 (+0300) Subject: Squelch 'Constant subroutine ... undefined' warnings from .ph files X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c0cc52e96e988526754ef533bd76595720660db2;p=p5sagit%2Fp5-mst-13.2.git Squelch 'Constant subroutine ... undefined' warnings from .ph files As reported by Christopher Zimmermann in , code generated from simple #undef directives by h2ph can cause 'Constant subroutine ... undefined' warnings if the undefined function was eligible for inlining. --- diff --git a/t/lib/h2ph.h b/t/lib/h2ph.h index 23f259e..78429ca 100644 --- a/t/lib/h2ph.h +++ b/t/lib/h2ph.h @@ -26,6 +26,10 @@ #undef MAX #define MAX(a,b) ((a) > (b) ? (a) : (b)) +/* Test #undef'ining an existing constant function */ +#define NOTTRUE 0 +#undef NOTTRUE + /* Test #ifdef */ #ifdef __SOME_UNIMPORTANT_PROPERTY #define MIN(a,b) ((a) < (b) ? (a) : (b)) diff --git a/t/lib/h2ph.pht b/t/lib/h2ph.pht index 01db98d..3723fca 100644 --- a/t/lib/h2ph.pht +++ b/t/lib/h2ph.pht @@ -1,6 +1,6 @@ require '_h2ph_pre.ph'; -no warnings 'redefine'; +no warnings qw(redefine misc); unless(defined(&SQUARE)) { sub SQUARE { @@ -22,6 +22,8 @@ unless(defined(&_H2PH_H_)) { my($a,$b) = @_; eval q((($a) > ($b) ? ($a) : ($b))); }' unless defined(&MAX); + eval 'sub NOTTRUE () {0;}' unless defined(&NOTTRUE); + undef(&NOTTRUE) if defined(&NOTTRUE); if(defined(&__SOME_UNIMPORTANT_PROPERTY)) { eval 'sub MIN { my($a,$b) = @_; diff --git a/utils/h2ph.PL b/utils/h2ph.PL index 6f40126..4e99a7a 100644 --- a/utils/h2ph.PL +++ b/utils/h2ph.PL @@ -123,7 +123,7 @@ while (defined (my $file = next_file())) { print OUT "require '_h2ph_pre.ph';\n\n", - "no warnings 'redefine';\n\n"; + "no warnings qw(redefine misc);\n\n"; while (defined (local $_ = next_line($file))) { if (s/^\s*\#\s*//) {