Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Apr 2015 18:42:39 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r281047 - head/contrib/llvm/patches
Message-ID:  <201504031842.t33IgdYf018405@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Fri Apr  3 18:42:38 2015
New Revision: 281047
URL: https://svnweb.freebsd.org/changeset/base/281047

Log:
  Add clang patch corresponding to r281046.

Added:
  head/contrib/llvm/patches/patch-12-clang-r227115-constantarraytype.diff

Added: head/contrib/llvm/patches/patch-12-clang-r227115-constantarraytype.diff
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/contrib/llvm/patches/patch-12-clang-r227115-constantarraytype.diff	Fri Apr  3 18:42:38 2015	(r281047)
@@ -0,0 +1,50 @@
+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.
+
+Introduced here: http://svnweb.freebsd.org/changeset/base/281046
+
+Index: tools/clang/lib/Sema/SemaInit.cpp
+===================================================================
+--- tools/clang/lib/Sema/SemaInit.cpp
++++ tools/clang/lib/Sema/SemaInit.cpp
+@@ -149,10 +149,10 @@ static void updateStringLiteralType(Expr *E, QualT
+ 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
+     // being initialized to a string literal.
+Index: tools/clang/test/SemaTemplate/instantiate-static-var.cpp
+===================================================================
+--- tools/clang/test/SemaTemplate/instantiate-static-var.cpp
++++ tools/clang/test/SemaTemplate/instantiate-static-var.cpp
+@@ -114,3 +114,15 @@ namespace PR6449 {
+   template class X1<char>;
+ 
+ }
++
++typedef char MyString[100];
++template <typename T>
++struct StaticVarWithTypedefString {
++  static MyString str;
++};
++template <typename T>
++MyString StaticVarWithTypedefString<T>::str = "";
++
++void testStaticVarWithTypedefString() {
++  (void)StaticVarWithTypedefString<int>::str;
++}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504031842.t33IgdYf018405>