diff options
author | Mike Stump <mrs@apple.com> | 2009-05-29 16:34:15 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-05-29 16:34:15 +0000 |
commit | fc30bf9b16ba79d615730ad2caa319dd2d260f73 (patch) | |
tree | af416ce2a76b497526f00cb0c3a0bb18b6a34987 /clang/lib/Sema | |
parent | de83126b80acf893a28ab88da1f3bf6ea497a4cf (diff) | |
download | bcm5719-llvm-fc30bf9b16ba79d615730ad2caa319dd2d260f73.tar.gz bcm5719-llvm-fc30bf9b16ba79d615730ad2caa319dd2d260f73.zip |
Avoid dumping during semantic analysis when checking array types when
a vla is used.
llvm-svn: 72575
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 5dc40a45934..6090b79c5c1 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -97,21 +97,22 @@ static void CheckStringInit(Expr *Str, QualType &DeclT, Sema &S) { return; } - const ConstantArrayType *CAT = cast<ConstantArrayType>(AT); - - // C99 6.7.8p14. We have an array of character type with known size. However, - // the size may be smaller or larger than the string we are initializing. - // FIXME: Avoid truncation for 64-bit length strings. - if (StrLength-1 > CAT->getSize().getZExtValue()) - S.Diag(Str->getSourceRange().getBegin(), - diag::warn_initializer_string_for_char_array_too_long) - << Str->getSourceRange(); - - // Set the type to the actual size that we are initializing. If we have - // something like: - // char x[1] = "foo"; - // then this will set the string literal's type to char[1]. - Str->setType(DeclT); + if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) { + // C99 6.7.8p14. We have an array of character type with known size. + // However, the size may be smaller or larger than the string we are + // initializing. + // FIXME: Avoid truncation for 64-bit length strings. + if (StrLength-1 > CAT->getSize().getZExtValue()) + S.Diag(Str->getSourceRange().getBegin(), + diag::warn_initializer_string_for_char_array_too_long) + << Str->getSourceRange(); + + // Set the type to the actual size that we are initializing. If we have + // something like: + // char x[1] = "foo"; + // then this will set the string literal's type to char[1]. + Str->setType(DeclT); + } } bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, |