<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 26, 2015, at 11:43 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Mon, Jan 26, 2015 at 11:04 AM, Ben Langmuir <</span><a href="mailto:blangmuir@apple.com" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">blangmuir@apple.com</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">> wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Author: benlangmuir<br class="">Date: Mon Jan 26 13:04:10 2015<br class="">New Revision: 227115<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=227115&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=227115&view=rev</a><br class="">Log:<br class="">Fix assert instantiating string init of static variable<br class=""><br class="">... when the variable's type is a typedef of a ConstantArrayType. Just<br class="">look through the typedef (and any other sugar).  We only use the<br class="">constant array type here to get the element count.<br class=""><br class="">Modified:<br class="">   cfe/trunk/lib/Sema/SemaInit.cpp<br class="">   cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp<br class=""><br class="">Modified: cfe/trunk/lib/Sema/SemaInit.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=227115&r1=227114&r2=227115&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=227115&r1=227114&r2=227115&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Sema/SemaInit.cpp (original)<br class="">+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Jan 26 13:04:10 2015<br class="">@@ -149,9 +149,9 @@ static void updateStringLiteralType(Expr<br class="">static void CheckStringInit(Expr *Str, QualType &DeclT, const ArrayType *AT,<br class="">                            Sema &S) {<br class="">  // Get the length of the string as parsed.<br class="">-  uint64_t StrLength =<br class="">-    cast<ConstantArrayType>(Str->getType())->getSize().getZExtValue();<br class="">-<br class="">+  auto *ConstantArrayTy =<br class="">+      cast<ConstantArrayType>(Str->getType()->getUnqualifiedDesugaredType());<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Please use getAsArrayTypeUnsafe() instead of getUnqualifiedDesugaredType() here.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>Thanks for the review.  Fixed in r227129</div><div><br class=""></div><div>Ben</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">+  uint64_t StrLength = ConstantArrayTy->getSize().getZExtValue();<br class=""><br class="">  if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(AT)) {<br class="">    // C99 6.7.8p14. We have an array of character type with unknown size<br class=""><br class="">Modified: cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp?rev=227115&r1=227114&r2=227115&view=diff" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp?rev=227115&r1=227114&r2=227115&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp (original)<br class="">+++ cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp Mon Jan 26 13:04:10 2015<br class="">@@ -114,3 +114,15 @@ namespace PR6449 {<br class="">  template class X1<char>;<br class=""><br class="">}<br class="">+<br class="">+typedef char MyString[100];<br class="">+template <typename T><br class="">+struct StaticVarWithTypedefString {<br class="">+  static MyString str;<br class="">+};<br class="">+template <typename T><br class="">+MyString StaticVarWithTypedefString<T>::str = "";<br class="">+<br class="">+void testStaticVarWithTypedefString() {<br class="">+  (void)StaticVarWithTypedefString<int>::str;<br class="">+}<br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@cs.uiuc.edu" class="">cfe-commits@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</blockquote></div></blockquote></div><br class=""></body></html>