summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/uninit-3.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>1999-03-11 16:00:04 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>1999-03-11 16:00:04 +0000
commitc010fb5b068a19bd1738f4ebb9665d4fb35d2762 (patch)
tree6dc897a58cfd0a75c3f1c7ed19c6746eccf11828 /gcc/testsuite/gcc.dg/uninit-3.c
parentd087657d05d68f46ab4a281cfa4332e86bfdc603 (diff)
downloadgcc-c010fb5b068a19bd1738f4ebb9665d4fb35d2762.tar.gz
`
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
Diffstat (limited to 'gcc/testsuite/gcc.dg/uninit-3.c')
-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 00000000000..78c4254dea5
--- /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;
+}