summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/compat/init/init-ref2_y.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/compat/init/init-ref2_y.C')
-rw-r--r--gcc/testsuite/g++.dg/compat/init/init-ref2_y.C24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/compat/init/init-ref2_y.C b/gcc/testsuite/g++.dg/compat/init/init-ref2_y.C
new file mode 100644
index 000000000..23e66b2f9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/compat/init/init-ref2_y.C
@@ -0,0 +1,24 @@
+extern int f (void);
+extern int r;
+
+const int *p;
+
+void g ()
+{
+ static const int &i = f();
+
+ // Test that i points to the same place in both calls.
+ if (p && p != &i)
+ ++r;
+ // Test that if so, it points to static data.
+ if (i != 42)
+ ++r;
+
+ p = &i;
+}
+
+void h ()
+{
+ int arr[] = { 1, 1, 1, 1, 1, 1, 1 };
+ g ();
+}