aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-24 16:07:07 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-25 00:20:08 +0200
commiteb6779f6f62173672b533cfbbff59758f710fb4f (patch)
tree378fcff18850d162fca82edb8dc9ffb545dc37c4 /validation
parent4c6cbe557c48205f9b3d2aae4c166cd66446b240 (diff)
downloadsparse-dev-eb6779f6f62173672b533cfbbff59758f710fb4f.tar.gz
generic: fix missing inlining of generic expression
Inlining in sparse works slightly differently than what my mental model is: the body is only evaluated after the inline expansion. IOW, an inline function is not evaluated until it is effectively inlined. That's fine but it means that generic expressions also need to be handled during the inlining. However, since the body of inline functions is evaluated just after inline expansion, so (recursively) copying the expression and its type - expression map is quite useless here. So, just copy the expression itself and its control expression to 'isolate' them from evaluation, evaluate it and then just copy the selected expression. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/inline-generic.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/validation/inline-generic.c b/validation/inline-generic.c
new file mode 100644
index 00000000..1f05c079
--- /dev/null
+++ b/validation/inline-generic.c
@@ -0,0 +1,10 @@
+extern int a, b;
+inline int c(void) { return a++; }
+inline int e(int d) { return 0; }
+inline unsigned f(void) { return e(_Generic(b, int: c())); }
+static int g(void) { return f(); }
+static int h(void) { return f(); }
+
+/*
+ * check-name: inline-generic
+ */