[cfe-commits] r41614 - /cfe/trunk/test/Sema/offsetof.c

Chris Lattner sabre at nondot.org
Thu Aug 30 10:51:09 PDT 2007


Author: lattner
Date: Thu Aug 30 12:51:09 2007
New Revision: 41614

URL: http://llvm.org/viewvc/llvm-project?rev=41614&view=rev
Log:
a new testcase

Added:
    cfe/trunk/test/Sema/offsetof.c

Added: cfe/trunk/test/Sema/offsetof.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/offsetof.c?rev=41614&view=auto

==============================================================================
--- cfe/trunk/test/Sema/offsetof.c (added)
+++ cfe/trunk/test/Sema/offsetof.c Thu Aug 30 12:51:09 2007
@@ -0,0 +1,23 @@
+// RUN: clang -parse-ast-check %s
+
+#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
+
+typedef struct P { int i; float f; } PT;
+struct external_sun3_core
+{
+ unsigned c_regs; 
+
+  PT  X[100];
+  
+};
+
+void swap()
+{
+  int x;
+  x = offsetof(struct external_sun3_core, c_regs);
+  x = __builtin_offsetof(struct external_sun3_core, X[42].f);
+  
+  x = __builtin_offsetof(struct external_sun3_core, X[42].f2);  // expected-error {{no member named 'f2'}}
+  x = __builtin_offsetof(int, X[42].f2);  // expected-error {{offsetof requires struct}}
+}    
+





More information about the cfe-commits mailing list