OSDN Git Service

PR c++/23180
authorjconner <jconner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Sep 2005 00:25:01 +0000 (00:25 +0000)
committerjconner <jconner@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Sep 2005 00:25:01 +0000 (00:25 +0000)
        * 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

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/struct2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/init/struct3.C [new file with mode: 0644]

index 7445b0d..e871629 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-13 Josh Conner <jconner@apple.com>
+
+       PR c++/23180
+       * g++.dg/init/struct2.C: New test.
+       * g++.dg/init/struct3.C: New test.
+
 2005-09-13  Janis Johnson  <janis187@us.ibm.com>
 
        * 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 (file)
index 0000000..d7d07b5
--- /dev/null
@@ -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 (file)
index 0000000..6b1805c
--- /dev/null
@@ -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;