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.

llvm-svn: 52113
This commit is contained in:
Eli Friedman 2008-06-09 03:52:40 +00:00
parent f54043b3d7
commit 7567573926
2 changed files with 15 additions and 1 deletions

View 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 {

View File

@ -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() };
}