Bug#379757: [PATCH 2/2] Squelch 'Constant subroutine ... undefined' warnings from .ph files

Niko Tyni ntyni at debian.org
Tue Apr 14 19:55:34 UTC 2009


As reported by Christopher Zimmermann in <http://bugs.debian.org/379757>,
code generated from simple #undef directives by h2ph can cause
'Constant subroutine ... undefined' warnings if the undefined
function was eligible for inlining.
---
 t/lib/h2ph.h   |    4 ++++
 t/lib/h2ph.pht |    4 +++-
 utils/h2ph.PL  |    2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

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*//) {
-- 
1.5.6.5







More information about the Perl-maintainers mailing list