aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-09 18:04:18 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-10-09 18:07:51 +0200
commit8d5756f55040e60adb1a8c3190e06a3822f4ff92 (patch)
tree974c1fe54e28eaa45bb1408890d3940f411c890e
parent0c6896f449e857baf10371301fe28dfb125a3208 (diff)
downloadsparse-8d5756f55040e60adb1a8c3190e06a3822f4ff92.tar.gz
flex-array: fix location for nesting of flexible members
The warning about the nesting of flexible array members is given with the location of the outer struct or union but that is not very interesting. What is needed is the location of the member causing this nesting. So, fix the warning message to use the member's location. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--symbol.c2
-rw-r--r--validation/flex-array-nested.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/symbol.c b/symbol.c
index 9ae827c1..5e7f0796 100644
--- a/symbol.c
+++ b/symbol.c
@@ -200,7 +200,7 @@ static struct symbol * examine_struct_union_type(struct symbol *sym, int advance
if (has_flexible_array(member))
info.has_flex_array = 1;
if (has_flexible_array(member) && Wflexible_array_nested)
- warning(sym->pos, "nested flexible arrays");
+ warning(member->pos, "nested flexible arrays");
fn(member, &info);
} END_FOR_EACH_PTR(member);
diff --git a/validation/flex-array-nested.c b/validation/flex-array-nested.c
index 63767683..a82cbfc9 100644
--- a/validation/flex-array-nested.c
+++ b/validation/flex-array-nested.c
@@ -23,7 +23,7 @@ static int foo(struct s *s, union u *u)
* check-command: sparse -Wflexible-array-nested $file
*
* check-error-start
-flex-array-nested.c:6:8: warning: nested flexible arrays
-flex-array-nested.c:10:7: warning: nested flexible arrays
+flex-array-nested.c:7:18: warning: nested flexible arrays
+flex-array-nested.c:11:18: warning: nested flexible arrays
* check-error-end
*/