summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2009-02-02 15:00:55 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2009-02-02 15:00:55 +0000
commit8877f99f9de829690bd14edded2fadbfe2675aec (patch)
tree5ebbf9dde8b5f7ccdb6f1908b8e4747cd420e365
parent6f361ff3450b5e61e53500269fbef5a7555f0f05 (diff)
downloadbcm5719-llvm-8877f99f9de829690bd14edded2fadbfe2675aec.tar.gz
bcm5719-llvm-8877f99f9de829690bd14edded2fadbfe2675aec.zip
fix PR3459: improve compatibility with gcc when checking for constant exprs
llvm-svn: 63517
-rw-r--r--clang/lib/Sema/SemaDecl.cpp7
-rw-r--r--clang/test/Sema/struct-decl.c10
2 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 5dd45fb072d..7d7badd2cb6 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -3128,10 +3128,9 @@ static QualType TryToFixInvalidVariablyModifiedType(QualType T,
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,
diff --git a/clang/test/Sema/struct-decl.c b/clang/test/Sema/struct-decl.c
new file mode 100644
index 00000000000..cacd8476582
--- /dev/null
+++ b/clang/test/Sema/struct-decl.c
@@ -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];
+};
OpenPOWER on IntegriCloud