Use the unqualified type for GCCs struct/union cast extension

llvm-svn: 62170
This commit is contained in:
Anders Carlsson 2009-01-13 17:00:51 +00:00
parent ffc6133318
commit bc12e92068
2 changed files with 16 additions and 2 deletions

View File

@ -1912,8 +1912,8 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr) {
// We can't check any more until template instantiation time.
} else if (!castType->isScalarType() && !castType->isVectorType()) {
// GCC struct/union extension: allow cast to self.
if (Context.getCanonicalType(castType) !=
Context.getCanonicalType(castExpr->getType()) ||
if (Context.getCanonicalType(castType).getUnqualifiedType() !=
Context.getCanonicalType(castExpr->getType().getUnqualifiedType()) ||
(!castType->isStructureType() && !castType->isUnionType())) {
// Reject any other conversions to non-scalar types.
return Diag(TyR.getBegin(), diag::err_typecheck_cond_expect_scalar)

View File

@ -0,0 +1,14 @@
// RUN: clang -fsyntax-only %s -verify
struct S {
int one;
int two;
};
struct S const foo(void);
struct S tmp;
void priv_sock_init() {
tmp = (struct S)foo();
}