[cfe-commits] r52113 - in /cfe/trunk: lib/Sema/SemaInit.cpp test/Sema/init-struct-qualified.c

Eli Friedman eli.friedman at gmail.com
Sun Jun 8 20:52:42 PDT 2008


Author: efriedma
Date: Sun Jun  8 22:52:40 2008
New Revision: 52113

URL: http://llvm.org/viewvc/llvm-project?rev=52113&view=rev
Log:
For struct initialization, check compatibility with the unqualified 
type; this isn't explicitly stated in the standard, but it doesn't 
really make sense for them to have an effect here.  Fixes the included 
testcase, sent to me by Steve Naroff.


Added:
    cfe/trunk/test/Sema/init-struct-qualified.c
Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=52113&r1=52112&r2=52113&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sun Jun  8 22:52:40 2008
@@ -165,7 +165,9 @@
   } else if (ElemType->isScalarType()) {
     CheckScalarType(IList, ElemType, Index);
   } else if (expr->getType()->getAsRecordType() &&
-             SemaRef->Context.typesAreCompatible(expr->getType(), ElemType)) {
+             SemaRef->Context.typesAreCompatible(
+               expr->getType().getUnqualifiedType(),
+               ElemType.getUnqualifiedType())) {
     Index++;
     // FIXME: Add checking
   } else {

Added: cfe/trunk/test/Sema/init-struct-qualified.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/init-struct-qualified.c?rev=52113&view=auto

==============================================================================
--- cfe/trunk/test/Sema/init-struct-qualified.c (added)
+++ cfe/trunk/test/Sema/init-struct-qualified.c Sun Jun  8 22:52:40 2008
@@ -0,0 +1,12 @@
+// RUN: clang -fsyntax-only -verify < %s
+typedef float CGFloat;
+typedef struct _NSPoint { CGFloat x; CGFloat y; } NSPoint;
+typedef struct _NSSize { CGFloat width; CGFloat height; } NSSize;
+typedef struct _NSRect { NSPoint origin; NSSize size; } NSRect;
+
+extern const NSPoint NSZeroPoint;
+
+extern NSSize canvasSize();
+void func() {
+   const NSRect canvasRect = { NSZeroPoint, canvasSize() };
+}





More information about the cfe-commits mailing list