]> andersk Git - splint.git/commitdiff
Added grammar support for compound literals. (Reported by Peter Anttu.)
authorevans1629 <evans1629>
Tue, 19 Feb 2002 13:17:59 +0000 (13:17 +0000)
committerevans1629 <evans1629>
Tue, 19 Feb 2002 13:17:59 +0000 (13:17 +0000)
test/Makefile.am
test/Makefile.in
test/compoundliterals.c [new file with mode: 0644]
test/compoundliterals.expect [new file with mode: 0644]
test/moreBufferTests2.expect

index 86108be14da82a8a3a83b88c7b5b8273fdd00ea8..6697c25d386bb2e928bc39b9342fb902c81c5bbd 100644 (file)
@@ -38,7 +38,7 @@ UNITTESTS = \
   help \
   abstptr abstract alias alttypes ansireserved argorder \
   args arraydims blocks break cases cast charlit clauses commentchar compdestroy \
-  constannot controldepth csyntax czechnames czechoslovaknames deadparam \
+  compoundliterals constannot controldepth csyntax czechnames czechoslovaknames deadparam \
   decl divzero enum exports external fields flags forbody format freearray \
   funcpointer functionmacro glob globals impabstract info init inparam internal iter keep libs \
   linked lintcomments list loopexec \
@@ -281,6 +281,10 @@ compdestroy:
        -$(SPLINTRN) compdestroy.c +checks -exportlocal -exportheader +strictdestroy +strictusereleased -expect 3
        -$(SPLINTRN) compdestroy.c +strict +partial -exportheader -expect 3
 
+.PHONY: compoundliterals
+compoundliterals:
+       ${SPLINTRN} compoundliterals.c 
+
 .PHONY: constannot
 constannot:
        ${SPLINTRN} constannot.c +boundswrite -exportlocal -expect 2
index ce4acccb2e1d14069eb3357d87cc4c5de4981fe8..7f318b39474a34fbdc3fd7e8f610f7d44adbc837 100644 (file)
@@ -115,7 +115,7 @@ UNITTESTS = \
   help \
   abstptr abstract alias alttypes ansireserved argorder \
   args arraydims blocks break cases cast charlit clauses commentchar compdestroy \
-  constannot controldepth csyntax czechnames czechoslovaknames deadparam \
+  compoundliterals constannot controldepth csyntax czechnames czechoslovaknames deadparam \
   decl divzero enum exports external fields flags forbody format freearray \
   funcpointer functionmacro glob globals impabstract info init inparam internal iter keep libs \
   linked lintcomments list loopexec \
@@ -1098,6 +1098,10 @@ compdestroy:
        -$(SPLINTRN) compdestroy.c +checks -exportlocal -exportheader +strictdestroy +strictusereleased -expect 3
        -$(SPLINTRN) compdestroy.c +strict +partial -exportheader -expect 3
 
+.PHONY: compoundliterals
+compoundliterals:
+       ${SPLINTRN} compoundliterals.c 
+
 .PHONY: constannot
 constannot:
        ${SPLINTRN} constannot.c +boundswrite -exportlocal -expect 2
diff --git a/test/compoundliterals.c b/test/compoundliterals.c
new file mode 100644 (file)
index 0000000..cf5e797
--- /dev/null
@@ -0,0 +1,20 @@
+/* Compound literals, added to C99 */
+struct simple {
+  int a;
+  int b;
+};
+
+typedef struct simple simple_t;
+
+int main (/*@unused@*/ int argc, /*@unused@*/ char **argv) {
+  /* This works */
+  struct simple simple1 = {1,2};
+  /* These don't */
+  struct simple simple2 = (struct simple){1,2};
+  simple_t simple3 = (((((((simple_t){1,2}))))));
+  simple2 = (struct simple) { 1, 2 };
+  printf("%d, %d\n", simple1.a, simple1.b);
+  printf("%d, %d\n", simple2.a, simple2.b);
+  printf("%d, %d\n", simple3.a, simple3.b);
+  return 1;
+}
diff --git a/test/compoundliterals.expect b/test/compoundliterals.expect
new file mode 100644 (file)
index 0000000..2b06c77
--- /dev/null
@@ -0,0 +1,2 @@
+
+Finished checking --- no warnings
index 78bc399897e0ac957d538aa6e283893ff2da131c..152baed0868909851b6ce6720da99c21955f2403 100644 (file)
@@ -13,9 +13,9 @@ fixedArrayType.c: (in function fixedArrayTouch)
 fixedArrayType.c:9:3: Possible out-of-bounds store:
     buffer[sizeof(Array) - 1]
     Unable to resolve constraint:
-    requires sizeof(Array) @ fixedArrayType.c:9:23 <= 10
+    requires sizeof(Array) @ fixedArrayType.c:9:24 <= 10
      needed to satisfy precondition:
     requires maxSet(buffer @ fixedArrayType.c:9:3) >= sizeof(Array) @
-    fixedArrayType.c:9:23 - 1
+    fixedArrayType.c:9:24 - 1
 
 Finished checking --- 1 code warning, as expected
This page took 0.050437 seconds and 5 git commands to generate.