diff mbox series

[03/17] add testcase for addressability of degenerated symbol

Message ID 20191210225921.94897-4-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series improve expansion of constant symbols | expand

Commit Message

Luc Van Oostenryck Dec. 10, 2019, 10:59 p.m. UTC
An array or a function that degenerates into a pointer
has its address implicitly taken since the result is
equivalent to '&array[0]' or '&fun'.

So, the corresponding symbol needs to be marked as
addressable, like when its address is explicitly taken.

Add a testcase to illustrate this.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/eval/addressable-degen.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 validation/eval/addressable-degen.c
diff mbox series

Patch

diff --git a/validation/eval/addressable-degen.c b/validation/eval/addressable-degen.c
new file mode 100644
index 000000000000..e1dc51079079
--- /dev/null
+++ b/validation/eval/addressable-degen.c
@@ -0,0 +1,18 @@ 
+extern void def(void *, unsigned int);
+
+static int bar(void)
+{
+	int x[2] = { 1, 2 };
+
+	def(x, sizeof(x));
+	return x[1];
+}
+
+/*
+ * check-name: eval/addressable-degen
+ * check-command: test-linearize -fdump-ir $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-contains: load\\.
+ */