mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
unifdef: Handle redefined symbols correctly.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D41758
(cherry picked from commit aacbe73842)
Approved by: re (gjb)
This commit is contained in:
1 parent
43e873278f
commit
0171f9ccfe
2 files changed
+26
-1
No files matched your search
@@ -1550,8 +1550,12 @@ addsym2(bool ignorethis, const char *symname, const char *val)
|
||||
sym->value = val;
|
||||
r = RB_INSERT(MACROMAP, ¯o_tree, sym);
|
||||
assert(r == NULL);
|
||||
debugsym("addsym", sym);
|
||||
} else {
|
||||
sym->ignore = ignorethis;
|
||||
sym->value = val;
|
||||
debugsym("updsym", sym);
|
||||
}
|
||||
debugsym("addsym", sym);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -17,6 +17,27 @@ EOF
|
||||
atf_check -o file:f unifdef <f
|
||||
}
|
||||
|
||||
atf_test_case redefine
|
||||
redefine_head() {
|
||||
atf_set descr "redefine the same symbol"
|
||||
}
|
||||
redefine_body() {
|
||||
cat >file <<EOF
|
||||
#if FOO
|
||||
a
|
||||
#else
|
||||
b
|
||||
#endif
|
||||
EOF
|
||||
atf_check -s exit:1 -o inline:"a\n" unifdef -DFOO <file
|
||||
atf_check -s exit:1 -o inline:"a\n" unifdef -UFOO -DFOO <file
|
||||
atf_check -s exit:1 -o inline:"a\n" unifdef -DFOO=0 -DFOO <file
|
||||
atf_check -s exit:1 -o inline:"b\n" unifdef -UFOO <file
|
||||
atf_check -s exit:1 -o inline:"b\n" unifdef -DFOO -UFOO <file
|
||||
atf_check -s exit:1 -o inline:"b\n" unifdef -DFOO -DFOO=0 <file
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case hash_comment
|
||||
atf_add_test_case redefine
|
||||
}
|
||||
Reference in new issue
Block a user