Ensure appending private variables in pattern-specific target variables.
authorPaul Smith <psmith@gnu.org>
Sun, 4 Mar 2012 08:09:09 +0000 (08:09 +0000)
committerPaul Smith <psmith@gnu.org>
Sun, 4 Mar 2012 08:09:09 +0000 (08:09 +0000)
Fixes Savannah bug #35468.

ChangeLog
expand.c
tests/ChangeLog
tests/scripts/variables/private

index e05b906..c7ea498 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-04  Paul Smith  <psmith@gnu.org>
+
+       * expand.c (variable_append): If the current set is local and the
+       next one is not a parent, then treat the next set as
+       local as well.  Fixes Savannah bug #35468.
+
 2012-03-03  Paul Smith  <psmith@gnu.org>
 
        * acinclude.m4 (AC_STRUCT_ST_MTIM_NSEC): Add support for AIX 5.2+
index e9c376c..9514483 100644 (file)
--- a/expand.c
+++ b/expand.c
@@ -497,6 +497,8 @@ variable_append (const char *name, unsigned int length,
 {
   const struct variable *v;
   char *buf = 0;
+  /* If this set is local and the next is not a parent, then next is local.  */
+  int nextlocal = local && set->next_is_parent == 0;
 
   /* If there's nothing left to check, return the empty buffer.  */
   if (!set)
@@ -507,12 +509,12 @@ variable_append (const char *name, unsigned int length,
 
   /* If there isn't one, or this one is private, try the set above us.  */
   if (!v || (!local && v->private_var))
-    return variable_append (name, length, set->next, 0);
+    return variable_append (name, length, set->next, nextlocal);
 
   /* If this variable type is append, first get any upper values.
      If not, initialize the buffer.  */
   if (v->append)
-    buf = variable_append (name, length, set->next, 0);
+    buf = variable_append (name, length, set->next, nextlocal);
   else
     buf = initialize_variable_output ();
 
index 7e7db50..9d98731 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-04  Paul Smith  <psmith@gnu.org>
+
+       * scripts/variables/private: Test appending private variables in
+       pattern-specific target rules.  See Savannah bug #35468.
+
 2012-03-03  Paul Smith  <psmith@gnu.org>
 
        * scripts/variables/SHELL: Ensure .SHELLFLAGS works with options
index 1797745..012274e 100644 (file)
@@ -87,4 +87,36 @@ bar1 bar2 bar3: ; @echo '$@: $(DEFS)'
 !,
               '', "bar3: FOO 3\nbar2: FOO\nbar1: FOO 1\n");
 
+# 10: Test append with pattern-specific variables and private
+
+run_make_test(q!
+IA = global
+PA = global
+PS = global
+S = global
+PS = global
+SV = global
+b%: IA += b%
+b%: private PA += b%
+b%: private PS = b%
+bar: all
+bar: IA += bar
+bar: private PA += bar
+bar: private PS = bar
+a%: IA += a%
+a%: private PA += a%
+a%: private PS = a%
+all: IA += all
+all: private PA += all
+all: private PS = all
+
+bar all: ; @echo '$@: IA=$(IA)'; echo '$@: PA=$(PA)'; echo '$@: PS=$(PS)'
+!,
+              '', "all: IA=global b% bar a% all
+all: PA=global a% all
+all: PS=all
+bar: IA=global b% bar
+bar: PA=global b% bar
+bar: PS=bar\n");
+
 1;