Pull in r227115 from upstream clang trunk (by Ben Langmuir):

Fix assert instantiating string init of static variable

  ... when the variable's type is a typedef of a ConstantArrayType. Just
  look through the typedef (and any other sugar).  We only use the
  constant array type here to get the element count.

This fixes an assertion failure when building the games/redeclipse port.

Reported by:	amdmi3
This commit is contained in:
Dimitry Andric 2015-04-03 18:38:37 +00:00
parent cc36fe4926
commit de460a4881
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=281046

View File

@ -149,9 +149,9 @@ static void updateStringLiteralType(Expr *E, QualType Ty) {
static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT,
Sema &S) {
// Get the length of the string as parsed.
uint64_t StrLength =
cast<ConstantArrayType>(Str->getType())->getSize().getZExtValue();
auto *ConstantArrayTy =
cast<ConstantArrayType>(Str->getType()->getUnqualifiedDesugaredType());
uint64_t StrLength = ConstantArrayTy->getSize().getZExtValue();
if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(AT)) {
// C99 6.7.8p14. We have an array of character type with unknown size