From: Douglas Gregor Date: Mon, 6 Jul 2009 15:38:40 +0000 (+0000) Subject: Fix bitfield promotion in the presence of explicit casts, from Abrama Bagnara. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f4a69a3107e7ff1569c747f7c6bdf7cff8cbf55;p=clang Fix bitfield promotion in the presence of explicit casts, from Abrama Bagnara. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74830 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 482e1062d8..50dfeebdbc 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -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(E)) if (FieldDecl *Field = dyn_cast(MemRef->getMemberDecl())) diff --git a/test/Sema/bitfield-promote.c b/test/Sema/bitfield-promote.c new file mode 100644 index 0000000000..42d4f5a196 --- /dev/null +++ b/test/Sema/bitfield-promote.c @@ -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