OSDN Git Service

`
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Mar 1999 16:00:04 +0000 (16:00 +0000)
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Mar 1999 16:00:04 +0000 (16:00 +0000)
Tests for various kinds of spurious uninit variable warning.
All are derived from cpplib; see comments in the files.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@25711 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/gcc.dg/uninit-3.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/uninit-3.c b/gcc/testsuite/gcc.dg/uninit-3.c
new file mode 100644 (file)
index 0000000..78c4254
--- /dev/null
@@ -0,0 +1,33 @@
+/* Spurious uninit variable warnings, case 3.
+   Inspired by cppexp.c (parse_charconst) */
+/* { dg-do compile } */
+/* { dg-options "-O -Wuninitialized" } */
+
+extern void error (char *);
+
+int
+parse_charconst (const char *start, const char *end)
+{
+  int c; /* { dg-bogus "c" "uninitialized variable warning" { xfail *-*-* } } */
+  int nchars, retval;
+
+  nchars = 0;
+  retval = 0;
+  while (start < end)
+    {
+      c = *start++;
+      if (c == '\'')
+       break;
+      nchars++;
+      retval += c;
+      retval <<= 8;
+    }
+
+  if (nchars == 0)
+    return 0;
+
+  if (c != '\'')
+    error ("malformed character constant");
+
+  return retval;
+}