[cfe-commits] r63517 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/struct-decl.c
Nuno Lopes
nunoplopes at sapo.pt
Mon Feb 2 07:00:55 PST 2009
Author: nlopes
Date: Mon Feb 2 09:00:55 2009
New Revision: 63517
URL: http://llvm.org/viewvc/llvm-project?rev=63517&view=rev
Log:
fix PR3459: improve compatibility with gcc when checking for constant exprs
Added:
cfe/trunk/test/Sema/struct-decl.c
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=63517&r1=63516&r2=63517&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Feb 2 09:00:55 2009
@@ -3128,10 +3128,9 @@
assert(EvalResult.Val.isInt() && "Size expressions must be integers!");
llvm::APSInt &Res = EvalResult.Val.getInt();
- if (Res > llvm::APSInt(Res.getBitWidth(), Res.isUnsigned()))
- return Context.getConstantArrayType(VLATy->getElementType(),
- Res, ArrayType::Normal, 0);
- return QualType();
+
+ return Context.getConstantArrayType(VLATy->getElementType(),
+ Res, ArrayType::Normal, 0);
}
bool Sema::VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
Added: cfe/trunk/test/Sema/struct-decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/struct-decl.c?rev=63517&view=auto
==============================================================================
--- cfe/trunk/test/Sema/struct-decl.c (added)
+++ cfe/trunk/test/Sema/struct-decl.c Mon Feb 2 09:00:55 2009
@@ -0,0 +1,10 @@
+// RUN: clang -fsyntax-only -verify %s
+
+// PR3459
+struct bar {
+ char n[1];
+};
+
+struct foo {
+ char name[(int)&((struct bar *)0)->n];
+};
More information about the cfe-commits
mailing list