[cfe-commits] r62170 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/struct-cast.c
Anders Carlsson
andersca at mac.com
Tue Jan 13 09:00:53 PST 2009
Author: andersca
Date: Tue Jan 13 11:00:51 2009
New Revision: 62170
URL: http://llvm.org/viewvc/llvm-project?rev=62170&view=rev
Log:
Use the unqualified type for GCCs struct/union cast extension
Added:
cfe/trunk/test/Sema/struct-cast.c
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=62170&r1=62169&r2=62170&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 13 11:00:51 2009
@@ -1912,8 +1912,8 @@
// 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)
Added: cfe/trunk/test/Sema/struct-cast.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-cast.c?rev=62170&view=auto
==============================================================================
--- cfe/trunk/test/Sema/struct-cast.c (added)
+++ cfe/trunk/test/Sema/struct-cast.c Tue Jan 13 11:00:51 2009
@@ -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();
+}
More information about the cfe-commits
mailing list