aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zack@gcc.gnu.org>1999-03-11 16:00:04 +0000
committerZack Weinberg <zack@gcc.gnu.org>1999-03-11 16:00:04 +0000
commitb6505b424925cbe61d9a6d28bf20d276f256a52b (patch)
tree6dc897a58cfd0a75c3f1c7ed19c6746eccf11828
parent85eb94a0e330830fa5ebb0313933f66fb845a634 (diff)
downloadgcc-b6505b424925cbe61d9a6d28bf20d276f256a52b.zip
gcc-b6505b424925cbe61d9a6d28bf20d276f256a52b.tar.gz
gcc-b6505b424925cbe61d9a6d28bf20d276f256a52b.tar.bz2
Tests for various kinds of spurious uninit variable warning.
` Tests for various kinds of spurious uninit variable warning. All are derived from cpplib; see comments in the files. From-SVN: r25711
-rw-r--r--gcc/testsuite/gcc.dg/uninit-3.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/uninit-3.c b/gcc/testsuite/gcc.dg/uninit-3.c
new file mode 100644
index 0000000..78c4254
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/uninit-3.c
@@ -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;
+}