[cfe-commits] r124637 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/CodeGen/struct-init.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Mon Jan 31 16:52:10 PST 2011
Author: akirtzidis
Date: Mon Jan 31 18:52:10 2011
New Revision: 124637
URL: http://llvm.org/viewvc/llvm-project?rev=124637&view=rev
Log:
When initializing struct members, the important thing is that the "initializing" expression is
compatible, not having the same type.
Fix rdar://8183908 in which compatible vector types weren't initialized properly leading to a crash.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CodeGen/struct-init.c
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=124637&r1=124636&r2=124637&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Jan 31 18:52:10 2011
@@ -697,7 +697,8 @@
// initial value of the object, including unnamed members, is
// that of the expression.
if ((ElemType->isRecordType() || ElemType->isVectorType()) &&
- SemaRef.Context.hasSameUnqualifiedType(expr->getType(), ElemType)) {
+ SemaRef.CheckSingleAssignmentConstraints(ElemType, expr)
+ == Sema::Compatible) {
SemaRef.DefaultFunctionArrayLvalueConversion(expr);
UpdateStructuredListElement(StructuredList, StructuredIndex, expr);
++Index;
Modified: cfe/trunk/test/CodeGen/struct-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/struct-init.c?rev=124637&r1=124636&r2=124637&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/struct-init.c (original)
+++ cfe/trunk/test/CodeGen/struct-init.c Mon Jan 31 18:52:10 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -emit-llvm -o -
+// RUN: %clang_cc1 %s -emit-llvm-only
typedef struct _zend_ini_entry zend_ini_entry;
struct _zend_ini_entry {
@@ -18,3 +18,14 @@
};
struct GLGENH ABHFBF = {1};
+
+typedef __attribute__(( ext_vector_type(2) )) unsigned int uint2;
+typedef __attribute__(( __vector_size__(8) )) unsigned int __neon_uint32x2_t;
+
+// rdar://8183908
+typedef struct __simd64_uint32_t {
+ __neon_uint32x2_t val;
+} uint32x2_t;
+void foo() {
+ const uint32x2_t signBit = { (uint2) 0x80000000 };
+}
More information about the cfe-commits
mailing list