]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
New test from PR #3230
authorGabriel Dos Reis <gdr@gcc.gnu.org>
Sat, 11 Aug 2001 20:21:55 +0000 (20:21 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Sat, 11 Aug 2001 20:21:55 +0000 (20:21 +0000)
From-SVN: r44807

gcc/testsuite/g++.dg/warn/return-reference.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/warn/return-reference.C b/gcc/testsuite/g++.dg/warn/return-reference.C
new file mode 100644 (file)
index 0000000..9c367ea
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+const int* bar();
+
+const int&
+foo1()
+{
+  static int empty;
+  const int* x = bar();
+  return (x ? *x : empty);
+}
+
+const int&
+foo2()
+{
+  static int empty;
+  const int* x = bar();
+  const int& r = (x ? *x : empty);
+  return (r);
+}
+