From: jconner Date: Wed, 14 Sep 2005 00:25:01 +0000 (+0000) Subject: PR c++/23180 X-Git-Tag: upstream/4.9.2~58647 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d91a309555ac21f2db1c4709552144391330f54a;p=platform%2Fupstream%2Flinaro-gcc.git PR c++/23180 * g++.dg/init/struct2.C: New test. * g++.dg/init/struct3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104254 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7445b0d..e871629 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2005-09-13 Josh Conner + + PR c++/23180 + * g++.dg/init/struct2.C: New test. + * g++.dg/init/struct3.C: New test. + 2005-09-13 Janis Johnson * gcc.dg/pr15784-4.c, gcc.dg/pr20130-1.c, gcc.dg/ucnid-6.c: diff --git a/gcc/testsuite/g++.dg/init/struct2.C b/gcc/testsuite/g++.dg/init/struct2.C new file mode 100644 index 0000000..d7d07b5 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/struct2.C @@ -0,0 +1,22 @@ +/* PR c++/23180. */ +/* Initialize a local structure with an expression that attempts to use + pointer arithmetic to calculate another structure field offset. */ + +void saveLoadEntries(const void *); + +void saveOrLoad() { + struct Track { + char soundName[15]; + }; + struct SaveLoadEntry { + int offs; + int type; + int size; + }; + + SaveLoadEntry trackEntries = { + ((long) (&((Track *) 42)->soundName[0])) - 42, + 0, 1 + }; + saveLoadEntries(&trackEntries); +} diff --git a/gcc/testsuite/g++.dg/init/struct3.C b/gcc/testsuite/g++.dg/init/struct3.C new file mode 100644 index 0000000..6b1805c --- /dev/null +++ b/gcc/testsuite/g++.dg/init/struct3.C @@ -0,0 +1,15 @@ +/* PR c++/23180. */ +/* Initialize a global variable with an expression that attempts to use + pointer arithmetic to calculate a structure field offset. */ + +struct Track { + char soundName[15]; +}; + +struct SaveLoadEntry { + int offs; + int type; + int size; +}; + +int foobar = ((long) (& ((Track *) 42)->soundName[0])) - 42;