[cfe-commits] r55493 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/PR2727.c test/Sema/PR2728.c
Daniel Dunbar
daniel at zuster.org
Thu Aug 28 11:42:21 PDT 2008
Author: ddunbar
Date: Thu Aug 28 13:42:20 2008
New Revision: 55493
URL: http://llvm.org/viewvc/llvm-project?rev=55493&view=rev
Log:
Fix isIntegerConstantExpr eval of __builtin_offsetof to return result
with correct width.
- PR2728.
Also, fix PR2727 test case.
Added:
cfe/trunk/test/Sema/PR2728.c
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/Sema/PR2727.c
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=55493&r1=55492&r2=55493&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Aug 28 13:42:20 2008
@@ -814,6 +814,7 @@
Result = ~Result;
break;
case UnaryOperator::OffsetOf:
+ Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType())));
Result = Exp->evaluateOffsetOf(Ctx);
}
break;
Modified: cfe/trunk/test/Sema/PR2727.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR2727.c?rev=55493&r1=55492&r2=55493&view=diff
==============================================================================
--- cfe/trunk/test/Sema/PR2727.c (original)
+++ cfe/trunk/test/Sema/PR2727.c Thu Aug 28 13:42:20 2008
@@ -1,3 +1,6 @@
+// RUN: clang -verify -fsyntax-only -std=c90 %s &&
+// RUN: clang -verify -fsyntax-only -std=c99 %s
+
int f (int x)
{
// sizeof applied to a type should not delete the type.
Added: cfe/trunk/test/Sema/PR2728.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/PR2728.c?rev=55493&view=auto
==============================================================================
--- cfe/trunk/test/Sema/PR2728.c (added)
+++ cfe/trunk/test/Sema/PR2728.c Thu Aug 28 13:42:20 2008
@@ -0,0 +1,9 @@
+// RUN: clang -verify -fsyntax-only -std=c90 %s &&
+// RUN: clang -verify -fsyntax-only -std=c99 %s
+
+struct s
+{
+ int a;
+};
+
+int a[__builtin_offsetof(struct s, a) == 0];
More information about the cfe-commits
mailing list