[arch-commits] Commit in llvm/trunk (PKGBUILD clang-3.1-fix-lwg-2141.patch)

Evangelos Foutras foutrelis at archlinux.org
Sun Nov 18 02:07:56 UTC 2012


    Date: Saturday, November 17, 2012 @ 21:07:55
  Author: foutrelis
Revision: 171484

upgpkg: llvm 3.1-6

Fix FS#32731: [clang] 3.1 fails to compile libstdc++ <chrono> 4.7.2

Added:
  llvm/trunk/clang-3.1-fix-lwg-2141.patch
Modified:
  llvm/trunk/PKGBUILD

------------------------------+
 PKGBUILD                     |   11 +++++-
 clang-3.1-fix-lwg-2141.patch |   65 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 3 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2012-11-18 01:59:48 UTC (rev 171483)
+++ PKGBUILD	2012-11-18 02:07:55 UTC (rev 171484)
@@ -11,7 +11,7 @@
 
 pkgname=('llvm' 'llvm-ocaml' 'clang' 'clang-analyzer')
 pkgver=3.1
-pkgrel=5
+pkgrel=6
 arch=('i686' 'x86_64')
 url="http://llvm.org/"
 license=('custom:University of Illinois/NCSA Open Source License')
@@ -25,7 +25,8 @@
         clang-pure64.patch
         enable-lto.patch
         llvm-3.1-fix-debug-line-info.patch
-        clang-3.1-fix-libprofile_rt.a-location.patch)
+        clang-3.1-fix-libprofile_rt.a-location.patch
+        clang-3.1-fix-lwg-2141.patch)
 sha256sums=('1ea05135197b5400c1f88d00ff280d775ce778f8f9ea042e25a1e1e734a4b9ab'
             'ff63e215dcd3e2838ffdea38502f8d35bab17e487f3c3799579961e452d5a786'
             '563d8a5ef86123ed8775e115ad7f90c1aa3e80f70b4e587f1bccab2c10753558'
@@ -35,7 +36,8 @@
             '288a82fbff17bc554f5863734246500e637882af33ee8511019d5e0d6cd20524'
             'f7145e203ffb4ce2c01976027f7840a9520e5341a9945f2459b6b11e5422d5b7'
             'db1f1aadebbc4c4232bdad49fb9b7dc61eac727085c63154b870fa9ce64fd18d'
-            '0d32ad283566357ca1bfbeb4cbe6b0b961943b79d3d718ed0435101c05629137')
+            '0d32ad283566357ca1bfbeb4cbe6b0b961943b79d3d718ed0435101c05629137'
+            'a3ac405a983643c9cb9081692a3f4d28e5d19571fa12b0517fb2b1f2acab0ad0')
 
 build() {
   cd "$srcdir/$pkgname-$pkgver.src"
@@ -81,6 +83,9 @@
   patch -d tools/clang -Np1 -i \
     "$srcdir/clang-3.1-fix-libprofile_rt.a-location.patch"
 
+  # Fix FS#32731: [clang] 3.1 fails to compile libstdc++ <chrono> 4.7.2
+  patch -d tools/clang -Np0 -i "$srcdir/clang-3.1-fix-lwg-2141.patch"
+
   # Fix FS#31098: LLVM 3.1 produces invalid debug information
   # http://llvm.org/bugs/show_bug.cgi?id=13211
   patch -Np1 -i "$srcdir/llvm-3.1-fix-debug-line-info.patch"

Added: clang-3.1-fix-lwg-2141.patch
===================================================================
--- clang-3.1-fix-lwg-2141.patch	                        (rev 0)
+++ clang-3.1-fix-lwg-2141.patch	2012-11-18 02:07:55 UTC (rev 171484)
@@ -0,0 +1,65 @@
+Index: test/SemaCXX/libstdcxx_common_type_hack.cpp
+===================================================================
+--- test/SemaCXX/libstdcxx_common_type_hack.cpp	(revision 0)
++++ test/SemaCXX/libstdcxx_common_type_hack.cpp	(revision 166455)
+@@ -0,0 +1,33 @@
++// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 -verify
++
++// This is a test for an egregious hack in Clang that works around
++// an issue with GCC's <type_traits> implementation. std::common_type
++// relies on pre-standard rules for decltype(), in which it doesn't
++// produce reference types so frequently.
++
++#ifdef BE_THE_HEADER
++
++#pragma GCC system_header
++namespace std {
++  template<typename T> T &&declval();
++
++  template<typename...Ts> struct common_type {};
++  template<typename A, typename B> struct common_type<A, B> {
++    // Under the rules in the standard, this always produces a
++    // reference type.
++    typedef decltype(true ? declval<A>() : declval<B>()) type;
++  };
++}
++
++#else
++
++#define BE_THE_HEADER
++#include "libstdcxx_common_type_hack.cpp"
++
++using T = int;
++using T = std::common_type<int, int>::type;
++
++using U = int; // expected-note {{here}}
++using U = decltype(true ? std::declval<int>() : std::declval<int>()); // expected-error {{different types}}
++
++#endif
+Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
+===================================================================
+--- lib/Sema/SemaTemplateInstantiateDecl.cpp	(revision 166454)
++++ lib/Sema/SemaTemplateInstantiateDecl.cpp	(revision 166455)
+@@ -158,6 +158,22 @@
+     SemaRef.MarkDeclarationsReferencedInType(D->getLocation(), DI->getType());
+   }
+ 
++  // HACK: g++ has a bug where it gets the value kind of ?: wrong.
++  // libstdc++ relies upon this bug in its implementation of common_type.
++  // If we happen to be processing that implementation, fake up the g++ ?:
++  // semantics. See LWG issue 2141 for more information on the bug.
++  const DecltypeType *DT = DI->getType()->getAs<DecltypeType>();
++  CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext());
++  if (DT && RD && isa<ConditionalOperator>(DT->getUnderlyingExpr()) &&
++      DT->isReferenceType() &&
++      RD->getEnclosingNamespaceContext() == SemaRef.getStdNamespace() &&
++      RD->getIdentifier() && RD->getIdentifier()->isStr("common_type") &&
++      D->getIdentifier() && D->getIdentifier()->isStr("type") &&
++      SemaRef.getSourceManager().isInSystemHeader(D->getLocStart()))
++    // Fold it to the (non-reference) type which g++ would have produced.
++    DI = SemaRef.Context.getTrivialTypeSourceInfo(
++      DI->getType().getNonReferenceType());
++
+   // Create the new typedef
+   TypedefNameDecl *Typedef;
+   if (IsTypeAlias)




More information about the arch-commits mailing list