From 16d40061cc9f0d8a842a752511801a1a1cfc3b77 Mon Sep 17 00:00:00 2001 From: evans1629 Date: Tue, 19 Feb 2002 13:17:59 +0000 Subject: [PATCH] Added grammar support for compound literals. (Reported by Peter Anttu.) --- test/Makefile.am | 6 +++++- test/Makefile.in | 6 +++++- test/compoundliterals.c | 20 ++++++++++++++++++++ test/compoundliterals.expect | 2 ++ test/moreBufferTests2.expect | 4 ++-- 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 test/compoundliterals.c create mode 100644 test/compoundliterals.expect diff --git a/test/Makefile.am b/test/Makefile.am index 86108be..6697c25 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 diff --git a/test/Makefile.in b/test/Makefile.in index ce4accc..7f318b3 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -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 index 0000000..cf5e797 --- /dev/null +++ b/test/compoundliterals.c @@ -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 index 0000000..2b06c77 --- /dev/null +++ b/test/compoundliterals.expect @@ -0,0 +1,2 @@ + +Finished checking --- no warnings diff --git a/test/moreBufferTests2.expect b/test/moreBufferTests2.expect index 78bc399..152baed 100644 --- a/test/moreBufferTests2.expect +++ b/test/moreBufferTests2.expect @@ -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 -- 2.45.1