]> granicus.if.org Git - clang/commitdiff
For struct initialization, check compatibility with the unqualified
authorEli Friedman <eli.friedman@gmail.com>
Mon, 9 Jun 2008 03:52:40 +0000 (03:52 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 9 Jun 2008 03:52:40 +0000 (03:52 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52113 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaInit.cpp
test/Sema/init-struct-qualified.c [new file with mode: 0644]

index 43adc2a82f94ee3a9b376885a5b3b2a288604b5d..e2377e18bae300b8f70d21dbe4b535f04aaec0cc 100644 (file)
@@ -165,7 +165,9 @@ void InitListChecker::CheckSubElementType(InitListExpr *IList,
   } 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 {
diff --git a/test/Sema/init-struct-qualified.c b/test/Sema/init-struct-qualified.c
new file mode 100644 (file)
index 0000000..37637e1
--- /dev/null
@@ -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() };
+}