]> granicus.if.org Git - clang/commitdiff
Fix bitfield promotion in the presence of explicit casts, from Abrama Bagnara.
authorDouglas Gregor <dgregor@apple.com>
Mon, 6 Jul 2009 15:38:40 +0000 (15:38 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 6 Jul 2009 15:38:40 +0000 (15:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74830 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/Expr.cpp
test/Sema/bitfield-promote.c [new file with mode: 0644]

index 482e1062d88cba17455515af892917acfa989bd2..50dfeebdbcdeeb70e7ca981c7db71e376e5f5912 100644 (file)
@@ -1458,7 +1458,7 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const
 }
 
 FieldDecl *Expr::getBitField() {
-  Expr *E = this->IgnoreParenCasts();
+  Expr *E = this->IgnoreParens();
 
   if (MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
     if (FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
diff --git a/test/Sema/bitfield-promote.c b/test/Sema/bitfield-promote.c
new file mode 100644 (file)
index 0000000..42d4f5a
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: clang -fsyntax-only -Xclang -verify %s
+struct {unsigned x : 2;} x;
+__typeof__((x.x+=1)+1) y;
+__typeof__(x.x<<1) y;
+int y;
+
+
+struct { int x : 8; } x1;
+long long y1;
+__typeof__(((long long)x1.x + 1)) y1;
\ No newline at end of file