autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] autoconf: warn if AC_*_IFELSE lacks complete program


From: Eric Blake
Subject: Re: [PATCH] autoconf: warn if AC_*_IFELSE lacks complete program
Date: Fri, 27 Aug 2010 07:59:00 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100806 Fedora/3.1.2-1.fc13 Mnenhy/0.8.3 Thunderbird/3.1.2

On 08/26/2010 11:24 PM, Ralf Wildenhues wrote:
Testing shows me that
   AC_INIT
   AC_PROG_CC
   AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED s])
   AC_COMPILE_IFELSE([t])

still manages to correctly warn about the second instance (might be a
good testsuite addition), but I fail to see how that is ensured.  Is
   m4_pushdef([M]) m4_define([M]) m4_popdef([M])

documented to work and do the expected (what would that be?) thing?

Yes - GNU m4 is documented where m4_define([a],[b]) is strictly equivalent to m4_popdef([a])m4_pushdef([b]) (with the special case that if [a] was not already defined, the m4_popdef([a]) action will not warn about popping an undefined variable). So it is always safe to use m4_define() to redefine the existing value of a variable; and when done inside an outer m4_pushdef/m4_popdef sequence, it has the net result of changing what the m4_pushdef did. M4sugar uses this concept in several places. (Some other m4 implementations are documented where m4_define wipes out the entire pushdef stack, rather than the top-most definition on the stack, and POSIX allows that alternate semantic, but it would break m4sugar.)

So, AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED]) effectively expands to:

m4_pushdef([a],[warn])m4_define([a],[nowarn])a()m4_popdef([a])

and by the time a() is called, it has the [nowarn] definition. On the other hand, AC_COMPILE_IFELSE(AC_LANG_DEFINES_PROVIDED) (note the missing quoting) expands to:

m4_define([a],[nowarn])m4_pushdef([a],[warn])a()m4_popdef([a])

and still issues a warning, because the AC_LANG_DEFINES_PROVIDED was expanded too early, and the expansion of a is still tied to the [warn] from the pushdef.

As for adding your example to the testsuite (of warning exactly once, and only on the second instance because the first was fine), yeah, that would make sense, so I'll try to get to that today.

--
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]