OSDN Git Service

* gcc.c-torture/execute/loop-12.c: New.
authoramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Apr 2002 03:52:22 +0000 (03:52 +0000)
committeramodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Apr 2002 03:52:22 +0000 (03:52 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52111 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/loop-12.c [new file with mode: 0644]

index ca52605..fae1c9b 100644 (file)
@@ -1,3 +1,7 @@
+2002-04-10  Alan Modra  <amodra@bigpond.net.au>
+
+       * gcc.c-torture/execute/loop-12.c: New.
+
 2002-04-08  Hans-Peter Nilsson  <hp@bitrange.com>
 
        * g77.f-torture/execute/980628-4.x,
diff --git a/gcc/testsuite/gcc.c-torture/execute/loop-12.c b/gcc/testsuite/gcc.c-torture/execute/loop-12.c
new file mode 100644 (file)
index 0000000..1e34099
--- /dev/null
@@ -0,0 +1,25 @@
+/* Checks that pure functions are not treated as const.  */
+
+char *p;
+
+static int __attribute__ ((pure))
+is_end_of_statement (void)
+{
+  return *p == '\n' || *p == ';' || *p == '!';
+}
+
+void foo (void)
+{
+  /* The is_end_of_statement call was moved out of the loop at one stage,
+     resulting in an endless loop.  */
+  while (!is_end_of_statement ())
+    p++;
+}
+
+int
+main (void)
+{
+  p = "abc\n";
+  foo ();
+  return 0;
+}