summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/offsetof5.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/other/offsetof5.C')
-rw-r--r--gcc/testsuite/g++.dg/other/offsetof5.C22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/other/offsetof5.C b/gcc/testsuite/g++.dg/other/offsetof5.C
new file mode 100644
index 000000000..3c4843380
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/offsetof5.C
@@ -0,0 +1,22 @@
+// PR c++/35741
+// { dg-do compile }
+
+#include <stddef.h>
+
+struct A
+{
+ char c;
+ int &i;
+};
+
+int j = offsetof (A, i); // { dg-warning "invalid access|offsetof" }
+
+template <typename T>
+struct S
+{
+ T h;
+ T &i;
+ static const int j = offsetof (S, i); // { dg-warning "invalid access|offsetof" }
+};
+
+int k = S<int>::j; // { dg-message "instantiated from here" }