[libcxx] r315278 - Remove unneeded typename from test

2017-10-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Oct 10 00:42:19 2017
New Revision: 315278

URL: http://llvm.org/viewvc/llvm-project?rev=315278&view=rev
Log:
Remove unneeded typename from test

Differential Revision: https://reviews.llvm.org/D38628


Modified:

libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp

libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp

Modified: 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp?rev=315278&r1=315277&r2=315278&view=diff
==
--- 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
 Tue Oct 10 00:42:19 2017
@@ -18,5 +18,5 @@
 int main()
 {
 typedef std::pair T;
-typename std::tuple_element<2, T>::type foo; // expected-error@utility:* 
{{Index out of bounds in std::tuple_element>}}
+std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index 
out of bounds in std::tuple_element>}}
 }

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp?rev=315278&r1=315277&r2=315278&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
 Tue Oct 10 00:42:19 2017
@@ -28,5 +28,5 @@
 
 int main() {
 using V = std::variant;
-typename std::variant_alternative<4, V>::type foo;  // 
expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
+std::variant_alternative<4, V>::type foo;  // expected-error@variant:* 
{{Index out of bounds in std::variant_alternative<>}}
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r315570 - Mark test as a long-test

2017-10-12 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Oct 12 01:46:05 2017
New Revision: 315570

URL: http://llvm.org/viewvc/llvm-project?rev=315570&view=rev
Log:
Mark test as a long-test

Differential Revision: https://reviews.llvm.org/D38452


Modified:

libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp?rev=315570&r1=315569&r2=315570&view=diff
==
--- 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.put.area/pbump2gig.pass.cpp
 Thu Oct 12 01:46:05 2017
@@ -13,6 +13,8 @@
 // class basic_streambuf;
 
 // void pbump(int n);
+//
+// REQUIRES: long_tests
 
 #include 
 #include 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r342060 - [RISCV] Explicitly set an empty --sysroot in the test

2018-09-12 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Sep 12 08:55:14 2018
New Revision: 342060

URL: http://llvm.org/viewvc/llvm-project?rev=342060&view=rev
Log:
[RISCV] Explicitly set an empty --sysroot in the test

In rL341655 we added additional behaviour to the Driver for riscv32-unknown-elf
when the sysroot is empty.

The new tests that check the new behaviour expect that the absence of --sysroot
in the command-line implies that the sysroot empty. This doesn't hold if clang
is built with a non-empty DEFAULT_SYSROOT in cmake. When this is the case, this
test fails.

Since the new behaviour is triggered when the sysroot is empty, pass an empty
--sysroot to avoid using the default (if any).

Differential Revision: https://reviews.llvm.org/D51972


Modified:
cfe/trunk/test/Driver/riscv32-toolchain.c

Modified: cfe/trunk/test/Driver/riscv32-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv32-toolchain.c?rev=342060&r1=342059&r2=342060&view=diff
==
--- cfe/trunk/test/Driver/riscv32-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv32-toolchain.c Wed Sep 12 08:55:14 2018
@@ -21,6 +21,7 @@
 
 // RUN: %clang %s -### -no-canonical-prefixes \
 // RUN:   -target riscv32-unknown-elf \
+// RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-BAREMETAL-NOSYSROOT-ILP32 %s
 
@@ -52,6 +53,7 @@
 
 // RUN: %clangxx %s -### -no-canonical-prefixes \
 // RUN:   -target riscv32-unknown-elf -stdlib=libstdc++ \
+// RUN:   --sysroot= \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv32_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV32-BAREMETAL-NOSYSROOT-ILP32 %s
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304523 - Mangle __unaligned in Itanium ABI

2017-06-02 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Fri Jun  2 02:14:34 2017
New Revision: 304523

URL: http://llvm.org/viewvc/llvm-project?rev=304523&view=rev
Log:
Mangle __unaligned in Itanium ABI

__unaligned is not currently mangled in any way in the Itanium ABI. This causes
failures when using -fms-extensions and C++ in targets using Itanium ABI.

As suggested by @rsmith the simplest thing to do here is actually mangle the
qualifier as a vendor extension.

This patch also removes the change done in D31976 and updates its test to the
new reality.

This fixes
  https://bugs.llvm.org/show_bug.cgi?id=33080
  https://bugs.llvm.org/show_bug.cgi?id=33178

Differential Revision: https://reviews.llvm.org/D33398


Added:
cfe/trunk/test/CodeGenCXX/pr33080.cpp
cfe/trunk/test/CodeGenCXX/unaligned-member-qualifier.cpp
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenObjCXX/arc-mangle.mm

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=304523&r1=304522&r2=304523&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Fri Jun  2 02:14:34 2017
@@ -1459,8 +1459,6 @@ void CXXNameMangler::mangleNestedName(co
 // We do not consider restrict a distinguishing attribute for overloading
 // purposes so we must not mangle it.
 MethodQuals.removeRestrict();
-// __unaligned is not currently mangled in any way, so remove it.
-MethodQuals.removeUnaligned();
 mangleQualifiers(MethodQuals);
 mangleRefQualifier(Method->getRefQualifier());
   }
@@ -2140,7 +2138,8 @@ CXXNameMangler::mangleOperatorName(Overl
 }
 
 void CXXNameMangler::mangleQualifiers(Qualifiers Quals) {
-  // Vendor qualifiers come first.
+  // Vendor qualifiers come first and if they are order-insensitive they must
+  // be emitted in reversed alphabetical order, see Itanium ABI 5.1.5.
 
   // Address space qualifiers start with an ordinary letter.
   if (Quals.hasAddressSpace()) {
@@ -2176,17 +2175,28 @@ void CXXNameMangler::mangleQualifiers(Qu
   }
 
   // The ARC ownership qualifiers start with underscores.
-  switch (Quals.getObjCLifetime()) {
   // Objective-C ARC Extension:
   //
   //::= U "__strong"
   //::= U "__weak"
   //::= U "__autoreleasing"
+  //
+  // Note: we emit __weak first to preserve the order as
+  // required by the Itanium ABI.
+  if (Quals.getObjCLifetime() == Qualifiers::OCL_Weak)
+mangleVendorQualifier("__weak");
+
+  // __unaligned (from -fms-extensions)
+  if (Quals.hasUnaligned())
+mangleVendorQualifier("__unaligned");
+
+  // Remaining ARC ownership qualifiers.
+  switch (Quals.getObjCLifetime()) {
   case Qualifiers::OCL_None:
 break;
 
   case Qualifiers::OCL_Weak:
-mangleVendorQualifier("__weak");
+// Do nothing as we already handled this case above.
 break;
 
   case Qualifiers::OCL_Strong:
@@ -4327,7 +4337,7 @@ bool CXXNameMangler::mangleSubstitution(
 /// substitutions.
 static bool hasMangledSubstitutionQualifiers(QualType T) {
   Qualifiers Qs = T.getQualifiers();
-  return Qs.getCVRQualifiers() || Qs.hasAddressSpace();
+  return Qs.getCVRQualifiers() || Qs.hasAddressSpace() || Qs.hasUnaligned();
 }
 
 bool CXXNameMangler::mangleSubstitution(QualType T) {

Added: cfe/trunk/test/CodeGenCXX/pr33080.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr33080.cpp?rev=304523&view=auto
==
--- cfe/trunk/test/CodeGenCXX/pr33080.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/pr33080.cpp Fri Jun  2 02:14:34 2017
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm -o- 
%s | FileCheck %s
+
+void fa(__unaligned struct A *) {}
+// CHECK: define void @_Z2faPU11__unaligned1A(
+
+void ga(struct A *, struct A *) {}
+// CHECK: define void @_Z2gaP1AS0_(
+
+void gb(__unaligned struct A *, struct A *) {}
+// CHECK: define void @_Z2gbPU11__unaligned1APS_(
+
+void gc(struct A *, __unaligned struct A *) {}
+// CHECK: define void @_Z2gcP1APU11__unalignedS_(
+
+void gd(__unaligned struct A *, __unaligned struct A *) {}
+// CHECK: define void @_Z2gdPU11__unaligned1AS1_(
+
+void hb(__unaligned struct A *, __unaligned const struct A *) {}
+// CHECK: define void @_Z2hbPU11__unaligned1APU11__unalignedKS_(
+
+void ja(__unaligned struct A *, __unaligned struct A *__unaligned *, 
__unaligned struct A *__unaligned *__unaligned *) {}
+// CHECK: define void 
@_Z2jaPU11__unaligned1APU11__unalignedS1_PU11__unalignedS3_(
+
+void jb(__unaligned struct A *, __unaligned struct A **, __unaligned struct A 
*__unaligned *__unaligned *) {}
+// CHECK: @_Z2jbPU11__unaligned1APS1_PU11__unalignedPU11__unalignedS1_(
+
+template 
+void ta(T &, Q *) {}
+
+void ia(__unaligned struct A &a) {
+  ta(a, &a);
+}
+// CHECK: @_Z2taIU11__unaligned1AS1_EvRT_PT0_(

Added: cfe/trunk/test/C

r304524 - Remove file that I forgot to remove as part of rL304523

2017-06-02 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Fri Jun  2 02:21:27 2017
New Revision: 304524

URL: http://llvm.org/viewvc/llvm-project?rev=304524&view=rev
Log:
Remove file that I forgot to remove as part of rL304523


Removed:
cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp

Removed: cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp?rev=304523&view=auto
==
--- cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp (removed)
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only 
%s -verify
-
-struct A
-{
-int x;
-void foo() __unaligned;
-void foo();
-};
-
-void A::foo() __unaligned
-{
-this->x++;
-}
-
-void A::foo() // expected-error {{definition with same mangled name as another 
definition}}
-  // expected-note@-6 {{previous definition is here}}
-{
-this->x++;
-}
-


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r356981 - [RISCV] Pass -target-abi to -cc1as

2019-03-26 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Mar 26 01:01:18 2019
New Revision: 356981

URL: http://llvm.org/viewvc/llvm-project?rev=356981&view=rev
Log:
[RISCV] Pass -target-abi to -cc1as

The RISC-V assembler needs the target ABI because it defines a flag of the ELF
file, as described in [1].

Make clang (the driver) to pass the target ABI to -cc1as in exactly the same
way it does for -cc1.

Currently -cc1as knows about -target-abi but is not handling it. Handle it and
pass it to the MC layer via MCTargetOptions.

[1] 
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#file-header

Differential Revision: https://reviews.llvm.org/D59298


Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.h
cfe/trunk/test/Driver/riscv-abi.c
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=356981&r1=356980&r2=356981&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Mar 26 01:01:18 2019
@@ -5931,6 +5931,15 @@ void ClangAs::AddX86TargetArgs(const Arg
   }
 }
 
+void ClangAs::AddRISCVTargetArgs(const ArgList &Args,
+   ArgStringList &CmdArgs) const {
+  const llvm::Triple &Triple = getToolChain().getTriple();
+  StringRef ABIName = riscv::getRISCVABI(Args, Triple);
+
+  CmdArgs.push_back("-target-abi");
+  CmdArgs.push_back(ABIName.data());
+}
+
 void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList 
&Inputs,
const ArgList &Args,
@@ -6100,6 +6109,11 @@ void ClangAs::ConstructJob(Compilation &
 CmdArgs.push_back("-arm-add-build-attributes");
 }
 break;
+
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64:
+AddRISCVTargetArgs(Args, CmdArgs);
+break;
   }
 
   // Consume all the warning flags. Usually this would be handled more

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.h?rev=356981&r1=356980&r2=356981&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.h Tue Mar 26 01:01:18 2019
@@ -119,6 +119,8 @@ public:
  llvm::opt::ArgStringList &CmdArgs) const;
   void AddX86TargetArgs(const llvm::opt::ArgList &Args,
 llvm::opt::ArgStringList &CmdArgs) const;
+  void AddRISCVTargetArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const;
   bool hasGoodDiagnostics() const override { return true; }
   bool hasIntegratedAssembler() const override { return false; }
   bool hasIntegratedCPP() const override { return false; }

Modified: cfe/trunk/test/Driver/riscv-abi.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-abi.c?rev=356981&r1=356980&r2=356981&view=diff
==
--- cfe/trunk/test/Driver/riscv-abi.c (original)
+++ cfe/trunk/test/Driver/riscv-abi.c Tue Mar 26 01:01:18 2019
@@ -2,6 +2,10 @@
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
+// RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32 %s
+// RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o \
+// RUN:   -mabi=ilp32 2>&1 | FileCheck -check-prefix=CHECK-ILP32 %s
 
 // CHECK-ILP32: "-target-abi" "ilp32"
 
@@ -26,6 +30,10 @@
 // RUN:   | FileCheck -check-prefix=CHECK-LP64 %s
 // RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -mabi=lp64 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LP64 %s
+// RUN: %clang -target riscv64-unknown-elf -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64  %s
+// RUN: %clang -target riscv64-unknown-elf -x assembler %s -### -o %t.o \
+// RUN:   -mabi=lp64 2>&1 | FileCheck -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: "-target-abi" "lp64"
 

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=356981&r1=356980&r2=356981&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Mar 26 01:01:18 2019
@@ -137,6 +137,10 @@ struct AssemblerInvocation {
   /// The name of the relocation model to use.
   std::string RelocationModel;
 
+  /// The ABI targeted by the backend. Specified using -targe

r367826 - Sidestep false positive due to a matching git repository name

2019-08-05 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Aug  5 03:09:06 2019
New Revision: 367826

URL: http://llvm.org/viewvc/llvm-project?rev=367826&view=rev
Log:
Sidestep false positive due to a matching git repository name

I have failures in this test because the grep @b gets confused by the
clang version including a repository name like this

!1 = !{!"clang version 10.0.0 (git@build-machine:llvm/llvm-monorepo.git 
fe958c0e8c89ec663c8e551936778e2cbb460154)"}

I considered something like grep -w but my understanding of the manpages
was that that isn't super portable. So I think it is easier to make
clang not to output that metadata using -fno-ident.

Differential Revision: https://reviews.llvm.org/D65635

Modified:
cfe/trunk/test/CodeGen/constant-comparison.c

Modified: cfe/trunk/test/CodeGen/constant-comparison.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/constant-comparison.c?rev=367826&r1=367825&r2=367826&view=diff
==
--- cfe/trunk/test/CodeGen/constant-comparison.c (original)
+++ cfe/trunk/test/CodeGen/constant-comparison.c Mon Aug  5 03:09:06 2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - 2>&1 | not grep warning
-// RUN: %clang_cc1 -emit-llvm %s -o - | grep @b | count 1
+// RUN: %clang_cc1 -fno-ident -emit-llvm %s -o - | grep @b | count 1
 
 int a, b;
 int *c1 = 1 < 2 ? &a : &b;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r368128 - [RISCV] Remove duplicated logic when determining the target ABI

2019-08-07 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Aug  7 00:08:00 2019
New Revision: 368128

URL: http://llvm.org/viewvc/llvm-project?rev=368128&view=rev
Log:
[RISCV] Remove duplicated logic when determining the target ABI

We were calculating twice ilp32/lp64. Do this in one place instead.

Differential Revision: https://reviews.llvm.org/D48357

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=368128&r1=368127&r2=368128&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Wed Aug  7 00:08:00 2019
@@ -372,8 +372,14 @@ void riscv::getRISCVTargetFeatures(const
 }
 
 StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
-  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
+  assert((Triple.getArch() == llvm::Triple::riscv32 ||
+  Triple.getArch() == llvm::Triple::riscv64) &&
+ "Unexpected triple");
+
+  if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
 return A->getValue();
 
+  // FIXME: currently defaults to the soft-float ABIs. Will need to be
+  // expanded to select ilp32f, ilp32d, lp64f, lp64d when appropriate.
   return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64";
 }

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=368128&r1=368127&r2=368128&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Aug  7 00:08:00 2019
@@ -1848,21 +1848,11 @@ void Clang::AddPPCTargetArgs(const ArgLi
 
 void Clang::AddRISCVTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
-  // FIXME: currently defaults to the soft-float ABIs. Will need to be
-  // expanded to select ilp32f, ilp32d, lp64f, lp64d when appropriate.
-  const char *ABIName = nullptr;
   const llvm::Triple &Triple = getToolChain().getTriple();
-  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
-ABIName = A->getValue();
-  else if (Triple.getArch() == llvm::Triple::riscv32)
-ABIName = "ilp32";
-  else if (Triple.getArch() == llvm::Triple::riscv64)
-ABIName = "lp64";
-  else
-llvm_unreachable("Unexpected triple!");
+  StringRef ABIName = riscv::getRISCVABI(Args, Triple);
 
   CmdArgs.push_back("-target-abi");
-  CmdArgs.push_back(ABIName);
+  CmdArgs.push_back(ABIName.data());
 }
 
 void Clang::AddSparcTargetArgs(const ArgList &Args,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r371492 - [RISCV] Move architecture parsing code into its own function

2019-09-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Sep 10 00:47:34 2019
New Revision: 371492

URL: http://llvm.org/viewvc/llvm-project?rev=371492&view=rev
Log:
[RISCV] Move architecture parsing code into its own function

I plan to reuse it in a later patch.

This is almost NFC except a small change in control flow when diagnosing
+d without +f.

Differential Revision: https://reviews.llvm.org/D66002

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=371492&r1=371491&r2=371492&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Tue Sep 10 00:47:34 2019
@@ -189,167 +189,177 @@ static void getExtensionFeatures(const D
   }
 }
 
-void riscv::getRISCVTargetFeatures(const Driver &D, const ArgList &Args,
-   std::vector &Features) {
-  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
-StringRef MArch = A->getValue();
+// Returns false if an error is diagnosed.
+static bool getArchFeatures(const Driver &D, StringRef MArch,
+std::vector &Features,
+const ArgList &Args) {
+  // RISC-V ISA strings must be lowercase.
+  if (llvm::any_of(MArch, [](char c) { return isupper(c); })) {
+D.Diag(diag::err_drv_invalid_riscv_arch_name)
+<< MArch << "string must be lowercase";
+return false;
+  }
 
-// RISC-V ISA strings must be lowercase.
-if (llvm::any_of(MArch, [](char c) { return isupper(c); })) {
-  D.Diag(diag::err_drv_invalid_riscv_arch_name)
-  << MArch << "string must be lowercase";
-  return;
-}
+  // ISA string must begin with rv32 or rv64.
+  if (!(MArch.startswith("rv32") || MArch.startswith("rv64")) ||
+  (MArch.size() < 5)) {
+D.Diag(diag::err_drv_invalid_riscv_arch_name)
+<< MArch << "string must begin with rv32{i,e,g} or rv64{i,g}";
+return false;
+  }
 
-// ISA string must begin with rv32 or rv64.
-if (!(MArch.startswith("rv32") || MArch.startswith("rv64")) ||
-(MArch.size() < 5)) {
-  D.Diag(diag::err_drv_invalid_riscv_arch_name) << MArch
-<< "string must begin with rv32{i,e,g} or rv64{i,g}";
-  return;
-}
+  bool HasRV64 = MArch.startswith("rv64");
 
-bool HasRV64 = MArch.startswith("rv64");
+  // The canonical order specified in ISA manual.
+  // Ref: Table 22.1 in RISC-V User-Level ISA V2.2
+  StringRef StdExts = "mafdqlcbjtpvn";
+  bool HasF = false, HasD = false;
+  char Baseline = MArch[4];
+
+  // First letter should be 'e', 'i' or 'g'.
+  switch (Baseline) {
+  default:
+D.Diag(diag::err_drv_invalid_riscv_arch_name)
+<< MArch << "first letter should be 'e', 'i' or 'g'";
+return false;
+  case 'e': {
+StringRef Error;
+// Currently LLVM does not support 'e'.
+// Extension 'e' is not allowed in rv64.
+if (HasRV64)
+  Error = "standard user-level extension 'e' requires 'rv32'";
+else
+  Error = "unsupported standard user-level extension 'e'";
+D.Diag(diag::err_drv_invalid_riscv_arch_name) << MArch << Error;
+return false;
+  }
+  case 'i':
+break;
+  case 'g':
+// g = imafd
+StdExts = StdExts.drop_front(4);
+Features.push_back("+m");
+Features.push_back("+a");
+Features.push_back("+f");
+Features.push_back("+d");
+HasF = true;
+HasD = true;
+break;
+  }
 
-// The canonical order specified in ISA manual.
-// Ref: Table 22.1 in RISC-V User-Level ISA V2.2
-StringRef StdExts = "mafdqlcbjtpvn";
-bool HasF = false, HasD = false;
-char Baseline = MArch[4];
+  // Skip rvxxx
+  StringRef Exts = MArch.substr(5);
 
-// First letter should be 'e', 'i' or 'g'.
-switch (Baseline) {
-default:
-  D.Diag(diag::err_drv_invalid_riscv_arch_name) << MArch
-<< "first letter should be 'e', 'i' or 'g'";
-  return;
-case 'e': {
+  // Remove non-standard extensions and supervisor-level extensions.
+  // They have 'x', 's', 'sx' prefixes. Parse them at the end.
+  // Find the very first occurrence of 's' or 'x'.
+  StringRef OtherExts;
+  size_t Pos = Exts.find_first_of("sx");
+  if (Pos != StringRef::npos) {
+OtherExts = Exts.substr(Pos);
+Exts = Exts.substr(0, Pos);
+  }
+
+  std::string Major, Minor;
+  if (!getExtensionVersion(D, MArch, std::string(1, Baseline), Exts, Major,
+   Minor))
+return false;
+
+  // TODO: Use version number when setting target features
+  // and consume the underscore '_' that might follow.
+
+  auto StdExtsItr = StdExts.begin();
+  auto StdExtsEnd = StdExts.end();
+
+  for (auto I = Exts.begin(), E = Exts.end(); I != E; ++I) {
+char c = *I;
+
+// Check ISA extensions are specified in the canonical order.
+while (StdExtsItr 

r371494 - [RISCV] Default to ilp32d/lp64d in RISC-V Linux

2019-09-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Sep 10 00:57:36 2019
New Revision: 371494

URL: http://llvm.org/viewvc/llvm-project?rev=371494&view=rev
Log:
[RISCV] Default to ilp32d/lp64d in RISC-V Linux

When running clang as a native compiler in RISC-V Linux the flag
-mabi=ilp32d / -mabi=lp64d is always mandatory. This change makes it the
default there.

Differential Revision: https://reviews.llvm.org/D65634

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
cfe/trunk/test/Driver/riscv32-toolchain.c
cfe/trunk/test/Driver/riscv64-toolchain.c
cfe/trunk/test/Preprocessor/riscv-target-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=371494&r1=371493&r2=371494&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Tue Sep 10 00:57:36 2019
@@ -389,7 +389,9 @@ StringRef riscv::getRISCVABI(const ArgLi
   if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ))
 return A->getValue();
 
-  // FIXME: currently defaults to the soft-float ABIs. Will need to be
-  // expanded to select ilp32f, ilp32d, lp64f, lp64d when appropriate.
-  return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64";
+  // RISC-V Linux defaults to ilp32d/lp64d
+  if (Triple.getOS() == llvm::Triple::Linux)
+return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32d" : "lp64d";
+  else
+return Triple.getArch() == llvm::Triple::riscv32 ? "ilp32" : "lp64";
 }

Modified: cfe/trunk/test/Driver/riscv32-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv32-toolchain.c?rev=371494&r1=371493&r2=371494&view=diff
==
--- cfe/trunk/test/Driver/riscv32-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv32-toolchain.c Tue Sep 10 00:57:36 2019
@@ -68,7 +68,7 @@
 // CXX-RV32-BAREMETAL-NOSYSROOT-ILP32: 
"{{.*}}/Inputs/basic_riscv32_tree/lib/gcc/riscv32-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv32-unknown-linux-gnu \
+// RUN:   -target riscv32-unknown-linux-gnu -mabi=ilp32 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32 %s
@@ -84,7 +84,7 @@
 // C-RV32-LINUX-MULTI-ILP32: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib32/ilp32"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv32-unknown-linux-gnu -march=rv32imafd -mabi=ilp32d \
+// RUN:   -target riscv32-unknown-linux-gnu -march=rv32imafd \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV32-LINUX-MULTI-ILP32D %s

Modified: cfe/trunk/test/Driver/riscv64-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv64-toolchain.c?rev=371494&r1=371493&r2=371494&view=diff
==
--- cfe/trunk/test/Driver/riscv64-toolchain.c (original)
+++ cfe/trunk/test/Driver/riscv64-toolchain.c Tue Sep 10 00:57:36 2019
@@ -68,7 +68,7 @@
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: 
"{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtend.o"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu \
+// RUN:   -target riscv64-unknown-linux-gnu -mabi=lp64 \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64 %s
@@ -84,7 +84,7 @@
 // C-RV64-LINUX-MULTI-LP64: 
"-L{{.*}}/Inputs/multilib_riscv_linux_sdk/sysroot/usr/lib64/lp64"
 
 // RUN: %clang %s -### -no-canonical-prefixes -fuse-ld=ld \
-// RUN:   -target riscv64-unknown-linux-gnu -march=rv64imafd -mabi=lp64d \
+// RUN:   -target riscv64-unknown-linux-gnu -march=rv64imafd \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-LINUX-MULTI-LP64D %s

Modified: cfe/trunk/test/Preprocessor/riscv-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/riscv-target-features.c?rev=371494&r1=371493&r2=371494&view=diff
==
--- cfe/trunk/test/Preprocessor/riscv-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/riscv-target-features.c Tue Sep 10 00:57:36 2019
@@ -48,9 +48,9 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1

r371496 - [RISCV] Make -march=rv{32, 64}gc the default in RISC-V Linux

2019-09-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Sep 10 01:16:24 2019
New Revision: 371496

URL: http://llvm.org/viewvc/llvm-project?rev=371496&view=rev
Log:
[RISCV] Make -march=rv{32,64}gc the default in RISC-V Linux

This is the logical follow-up of D65634.

Differential Revision: https://reviews.llvm.org/D66003

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/riscv-features.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=371496&r1=371495&r2=371496&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Tue Sep 10 01:16:24 2019
@@ -12,6 +12,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/raw_ostream.h"
 #include "ToolChains/CommonArgs.h"
@@ -353,14 +354,18 @@ static bool getArchFeatures(const Driver
   return true;
 }
 
-void riscv::getRISCVTargetFeatures(const Driver &D, const ArgList &Args,
+void riscv::getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
+   const ArgList &Args,
std::vector &Features) {
-  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
-StringRef MArch = A->getValue();
+  llvm::Optional MArch;
+  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
+MArch = A->getValue();
+  else if (Triple.getOS() == llvm::Triple::Linux)
+// RISC-V Linux defaults to rv{32,64}gc.
+MArch = Triple.getArch() == llvm::Triple::riscv32 ? "rv32gc" : "rv64gc";
 
-if (!getArchFeatures(D, MArch, Features, Args))
-  return;
-  }
+  if (MArch.hasValue() && !getArchFeatures(D, *MArch, Features, Args))
+return;
 
   // -mrelax is default, unless -mno-relax is specified.
   if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, true))

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.h?rev=371496&r1=371495&r2=371496&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.h Tue Sep 10 01:16:24 2019
@@ -19,7 +19,8 @@ namespace clang {
 namespace driver {
 namespace tools {
 namespace riscv {
-void getRISCVTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
+void getRISCVTargetFeatures(const Driver &D, const llvm::Triple &Triple,
+const llvm::opt::ArgList &Args,
 std::vector &Features);
 StringRef getRISCVABI(const llvm::opt::ArgList &Args,
   const llvm::Triple &Triple);

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=371496&r1=371495&r2=371496&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep 10 01:16:24 2019
@@ -336,7 +336,7 @@ static void getTargetFeatures(const Tool
 break;
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
-riscv::getRISCVTargetFeatures(D, Args, Features);
+riscv::getRISCVTargetFeatures(D, Triple, Args, Features);
 break;
   case llvm::Triple::systemz:
 systemz::getSystemZTargetFeatures(Args, Features);

Modified: cfe/trunk/test/Driver/riscv-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-features.c?rev=371496&r1=371495&r2=371496&view=diff
==
--- cfe/trunk/test/Driver/riscv-features.c (original)
+++ cfe/trunk/test/Driver/riscv-features.c Tue Sep 10 01:16:24 2019
@@ -18,4 +18,15 @@
 
 // SAVE-RESTORE: warning: the clang compiler does not support '-msave-restore'
 // NO-SAVE-RESTORE-NOT: warning: the clang compiler does not support
-// DEFAULT-NOT: warning: the clang compiler does not support
\ No newline at end of file
+// DEFAULT-NOT: warning: the clang compiler does not support
+
+// RUN: %clang -target riscv32-linux -### %s -fsyntax-only 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=DEFAULT-LINUX
+// RUN: %clang -target riscv64-linux -### %s -fsyntax-only 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=DEFAULT-LINUX
+
+// DEFAULT-LINUX: "-target-feature" "+m"
+// DEFAULT-LINUX-SAME: "-target-feature" "+a"
+// DEFAULT-LINUX-SAME: "-target-feature" "+f"
+// DEFAULT-LINUX-SAME: "-target-feature" "+d"
+// DEFAULT-LINUX-SAME: "-target-feature" "+c"


__

Re: [PATCH] D23657: Remove some false positives when taking the address of packed members

2016-09-23 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-09-30 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r278483 - This patch implements PR#22821.

2016-10-03 Thread Roger Ferrer Ibanez via cfe-commits
Hi Joerg,

thanks for your comments. I agree that these false positives are annoying.

I submitted a while ago a patch to address those false positives in 
https://reviews.llvm.org/D23657 but it is pending approval.

Kind regards,
Roger

> -Original Message-
> From: Joerg Sonnenberger [mailto:jo...@bec.de]
> Sent: 02 October 2016 07:24
> To: cfe-commits@lists.llvm.org
> Cc: Roger Ferrer Ibanez
> Subject: Re: r278483 - This patch implements PR#22821.
> 
> On Sat, Oct 01, 2016 at 11:28:39PM +0200, Joerg Sonnenberger via cfe-
> commits wrote:
> > On Fri, Aug 12, 2016 at 08:04:13AM -, Roger Ferrer Ibanez via cfe-
> commits wrote:
> > > Author: rogfer01
> > > Date: Fri Aug 12 03:04:13 2016
> > > New Revision: 278483
> > >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=278483&view=rev
> > > Log:
> > > This patch implements PR#22821.
> > >
> > > Taking the address of a packed member is dangerous since the reduced
> > > alignment of the pointee is lost. This can lead to memory alignment
> > > faults in some architectures if the pointer value is dereferenced.
> >
> > This triggers on LVM in a rather obvious false positive:
> >
> > (uintptr_t) &lh->offset_xl
> >
> > Given that one correct use case is to take the address and cast it to
> > void * (or uintptr_t) for use without caring about alignment, the
> > warning clearly needs to be refined.
> 
> Looking more at it, I request this warning to be disabled by default. In
> the current form it is useless and just makes it impossible to use
> packed structures at all. Before reenabling, it should handling:
> (1) Assignment to pointer with reduced alignment
> (2) Casts to pointer with reduced alignment
> (3) Use as function argument with implicit cast like (2).
> 
> at the very least to cover normal use of packed member pointers.
> 
> Joerg

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-04 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 73466.
rogfer01 added a comment.

Change algorithm following @rsmith suggestions by computing the offset of the 
whole access and compare it against the expected alignment, so reduced aligned 
structs inside overaligned structs does not yield a warning.

Also ignore parentheses where necessary, which was effectively preventing 
silencing some false positives.

Includes testcases suggested by @rsmith and @joerg.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,65 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void foo()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* bar() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11286,45 +11286,103 @@
 }
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
-  if (!T->isPointerType())
+  E = E->IgnoreParens();
+  if (!T->isPointerType() && !T->isIntegerType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
   auto MA = std::find(MisalignedMembers.

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-04 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

@arphaman thanks for the testcase! Will do.


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-14 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 74638.
rogfer01 added a comment.

Updated patch, now we check if the innermost base of a MemberExpr is a 
DeclRefExpr and check for its declaration in case it provides stronger 
alignment guarantees.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,120 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void g8()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* g9() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
+
+struct S9 {
+  uint32_t x;
+  uint8_t y[2];
+  uint16_t z;
+} __attribute__((__packed__));
+
+typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
+
+void g10() {
+  struct S9 x;
+  struct S9 __attribute__((__aligned__(8))) y;
+  aligned_S9 z;
+
+  uint32_t *p32;
+  p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}}
+  p32 = &y.x; // no-warning
+  p32 = &z.x; // no-warning
+}
+
+typedef struct {
+  uint32_t msgh_bits;
+  uint32_t msgh_size;
+  int32_t msgh_voucher_port;
+  int32_t msgh_id;
+} S10Header;
+
+typedef struct {
+  uint32_t t;
+  uint64_t m;
+  uint32_t p;
+  union {
+struct {
+  uint32_t a;
+  double z;
+} __attribute__((aligned(8), packed)) a;
+struct {
+  uint32_t b;
+  double z;
+  

r320017 - Ignore pointers to incomplete types when diagnosing misaligned addresses

2017-12-07 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  7 01:23:50 2017
New Revision: 320017

URL: http://llvm.org/viewvc/llvm-project?rev=320017&view=rev
Log:
Ignore pointers to incomplete types when diagnosing misaligned addresses

This is a fix for PR35509 in which we crash because we attempt to compute the
alignment of an incomplete type.

Differential Revision: https://reviews.llvm.org/D40895


Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=320017&r1=320016&r2=320017&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Dec  7 01:23:50 2017
@@ -12399,8 +12399,9 @@ void Sema::DiscardMisalignedMemberAddres
   MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
   (T->isIntegerType() ||
-   (T->isPointerType() &&
-Context.getTypeAlignInChars(T->getPointeeType()) <= 
MA->Alignment)))
+   (T->isPointerType() && (T->getPointeeType()->isIncompleteType() ||
+   Context.getTypeAlignInChars(
+   T->getPointeeType()) <= 
MA->Alignment
 MisalignedMembers.erase(MA);
 }
   }

Modified: cfe/trunk/test/SemaCXX/address-packed.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/address-packed.cpp?rev=320017&r1=320016&r2=320017&view=diff
==
--- cfe/trunk/test/SemaCXX/address-packed.cpp (original)
+++ cfe/trunk/test/SemaCXX/address-packed.cpp Thu Dec  7 01:23:50 2017
@@ -112,3 +112,12 @@ void g1() {
   S s3;
   s3.get(); // expected-note {{in instantiation of member function 
'S::get'}}
 }
+
+// PR35509
+typedef long L1;
+struct Incomplete;
+struct S2 {
+  L1 d;
+  Incomplete *e() const;
+} __attribute__((packed));
+Incomplete *S2::e() const { return (Incomplete *)&d; } // no-warning


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r320363 - [libcxx] Define istream_iterator equality comparison operators out-of-line

2017-12-11 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Dec 11 05:54:58 2017
New Revision: 320363

URL: http://llvm.org/viewvc/llvm-project?rev=320363&view=rev
Log:
[libcxx] Define istream_iterator equality comparison operators out-of-line

Currently libc++ defines operator== and operator!= as friend functions in the
definition of the istream_iterator class template. Such definition has a subtle
difference from an out-of-line definition required by the C++ Standard: these
functions can only be found by argument-dependent lookup, but not by qualified
lookup.

This patch changes the definition, so that it conforms to the C++ Standard and
adds a check involving qualified lookup to the test suite.

Patch contributed by Mikhail Maltsev.

Differential Revision: https://reviews.llvm.org/D40415


Modified:
libcxx/trunk/include/iterator

libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp

Modified: libcxx/trunk/include/iterator
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/iterator?rev=320363&r1=320362&r2=320363&view=diff
==
--- libcxx/trunk/include/iterator (original)
+++ libcxx/trunk/include/iterator Mon Dec 11 05:54:58 2017
@@ -904,15 +904,37 @@ public:
 _LIBCPP_INLINE_VISIBILITY istream_iterator  operator++(int)
 {istream_iterator __t(*this); ++(*this); return __t;}
 
+template 
 friend _LIBCPP_INLINE_VISIBILITY
-bool operator==(const istream_iterator& __x, const istream_iterator& __y)
-{return __x.__in_stream_ == __y.__in_stream_;}
+bool
+operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
+   const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
 
+template 
 friend _LIBCPP_INLINE_VISIBILITY
-bool operator!=(const istream_iterator& __x, const istream_iterator& __y)
-{return !(__x == __y);}
+bool
+operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x,
+   const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y);
 };
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
+   const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
+{
+return __x.__in_stream_ == __y.__in_stream_;
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+bool
+operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x,
+   const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y)
+{
+return !(__x == __y);
+}
+
 template  >
 class _LIBCPP_TEMPLATE_VIS ostream_iterator
 : public iterator

Modified: 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp?rev=320363&r1=320362&r2=320363&view=diff
==
--- 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/iterators/stream.iterators/istream.iterator/istream.iterator.ops/equal.pass.cpp
 Mon Dec 11 05:54:58 2017
@@ -49,4 +49,7 @@ int main()
 
 assert(i4 == i4);
 assert(i4 == i5);
+
+assert(std::operator==(i1, i2));
+assert(std::operator!=(i1, i3));
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bfb7736 - [OpenMP] Fix accidental reuse of VLA size

2021-08-06 Thread Roger Ferrer Ibanez via cfe-commits
Author: Roger Ferrer Ibanez
Date: 2021-08-07T05:55:27Z
New Revision: bfb77364d0be8a5b159cdcf4eaf8e7a720802e89

URL: 
https://github.com/llvm/llvm-project/commit/bfb77364d0be8a5b159cdcf4eaf8e7a720802e89
DIFF: 
https://github.com/llvm/llvm-project/commit/bfb77364d0be8a5b159cdcf4eaf8e7a720802e89.diff

LOG: [OpenMP] Fix accidental reuse of VLA size

We were using an OpaqueValueExpr allocated on the stack to store
the size of a VLA. Because the VLASizeMap in CodegenFunction
uses the address of the expression to avoid recomputing VLAs,
we were accidentally reusing an earlier llvm::Value. This led to
invalid LLVM IR.

This is a temporary solution until VLASizeMap can be pushed and popped
based on the context.

Differential Revision: https://reviews.llvm.org/D107666

Added: 
clang/test/OpenMP/vla_iterator_cache_bug.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index ca98c7a57446..90fcf2232be2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4401,14 +4401,14 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, 
SourceLocation Loc,
 if (NumOfElements) {
   NumOfElements = CGF.Builder.CreateNUWAdd(
   llvm::ConstantInt::get(CGF.SizeTy, NumAffinities), NumOfElements);
-  OpaqueValueExpr OVE(
+  auto *OVE = new (C) OpaqueValueExpr(
   Loc,
   C.getIntTypeForBitwidth(C.getTypeSize(C.getSizeType()), 
/*Signed=*/0),
   VK_PRValue);
-  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, &OVE,
+  CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
 
RValue::get(NumOfElements));
   KmpTaskAffinityInfoArrayTy =
-  C.getVariableArrayType(KmpTaskAffinityInfoTy, &OVE, 
ArrayType::Normal,
+  C.getVariableArrayType(KmpTaskAffinityInfoTy, OVE, ArrayType::Normal,
  /*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
   // Properly emit variable-sized array.
   auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy,
@@ -4899,13 +4899,13 @@ std::pair 
CGOpenMPRuntime::emitDependClause(
   NumOfElements =
   CGF.Builder.CreateNUWAdd(NumOfRegularWithIterators, NumOfElements);
 }
-OpaqueValueExpr OVE(Loc,
-C.getIntTypeForBitwidth(/*DestWidth=*/64, 
/*Signed=*/0),
-VK_PRValue);
-CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, &OVE,
+auto *OVE = new (C) OpaqueValueExpr(
+Loc, C.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0),
+VK_PRValue);
+CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
   RValue::get(NumOfElements));
 KmpDependInfoArrayTy =
-C.getVariableArrayType(KmpDependInfoTy, &OVE, ArrayType::Normal,
+C.getVariableArrayType(KmpDependInfoTy, OVE, ArrayType::Normal,
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
 // CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy);
 // Properly emit variable-sized array.

diff  --git a/clang/test/OpenMP/vla_iterator_cache_bug.c 
b/clang/test/OpenMP/vla_iterator_cache_bug.c
new file mode 100644
index ..ad5a664346e2
--- /dev/null
+++ b/clang/test/OpenMP/vla_iterator_cache_bug.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+extern int bounds1(int);
+extern int bounds2(int);
+
+extern void fun2(int n, int *a, int *b);
+extern void fun3(int n, int *a, int *b);
+
+void fun1(int n, int *a, int *b)
+{
+#pragma omp task depend(iterator(j = 0 : bounds1(n)), in : a[b[j]])
+  {
+fun2(n, a, b);
+  }
+// CHECK: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA:%.*]], align 16
+
+#pragma omp task depend(iterator(j = 0 : bounds2(n)), in : a[b[j]])
+  {
+fun3(n, a, b);
+  }
+// CHECK-NOT: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA]], align 16
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3174766 - [Docs] Fix code-blocks missing a colon and a newline

2023-07-27 Thread Roger Ferrer Ibanez via cfe-commits
Author: Roger Ferrer Ibanez
Date: 2023-07-28T05:36:49Z
New Revision: 31747668325227013e4cdd2c7aa185110485

URL: 
https://github.com/llvm/llvm-project/commit/31747668325227013e4cdd2c7aa185110485
DIFF: 
https://github.com/llvm/llvm-project/commit/31747668325227013e4cdd2c7aa185110485.diff

LOG: [Docs] Fix code-blocks missing a colon and a newline

Fix syntax issues in the reStructuredText file that prevented rendering them.

Differential Revision: https://reviews.llvm.org/D156438

Added: 


Modified: 

clang-tools-extra/docs/clang-tidy/checks/bugprone/bad-signal-to-kill-thread.rst

clang-tools-extra/docs/clang-tidy/checks/bugprone/spuriously-wake-up-functions.rst

clang-tools-extra/docs/clang-tidy/checks/concurrency/thread-canceltype-asynchronous.rst
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticGroups.td
llvm/docs/ORCv2.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/bad-signal-to-kill-thread.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/bad-signal-to-kill-thread.rst
index 8bf5ab17af5c9c..24b08da6c5c30b 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/bad-signal-to-kill-thread.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/bad-signal-to-kill-thread.rst
@@ -7,7 +7,7 @@ Finds ``pthread_kill`` function calls when a thread is 
terminated by
 raising ``SIGTERM`` signal and the signal kills the entire process, not
 just the individual thread. Use any signal except ``SIGTERM``.
 
-.. code-block: c++
+.. code-block:: c++
 
 pthread_kill(thread, SIGTERM);
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/spuriously-wake-up-functions.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/spuriously-wake-up-functions.rst
index c1bd8f3c7fdd0e..1b5bab2143a2dd 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/spuriously-wake-up-functions.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/spuriously-wake-up-functions.rst
@@ -8,13 +8,13 @@ Finds ``cnd_wait``, ``cnd_timedwait``, ``wait``, 
``wait_for``, or
 that checks whether a condition predicate holds or the function has a
 condition parameter.
 
-.. code-block: c++
+.. code-block:: c++
 
 if (condition_predicate) {
 condition.wait(lk);
 }
 
-.. code-block: c
+.. code-block:: c
 
 if (condition_predicate) {
 if (thrd_success != cnd_wait(&condition, &lock)) {

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/concurrency/thread-canceltype-asynchronous.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/concurrency/thread-canceltype-asynchronous.rst
index 7f058a89a2c39a..11edd001365d14 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/concurrency/thread-canceltype-asynchronous.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/concurrency/thread-canceltype-asynchronous.rst
@@ -10,7 +10,7 @@ type is set to asynchronous. Asynchronous cancellation type
 cancellation, a cancellation point in an asynchronous signal handler may still
 be acted upon and the effect is as if it was an asynchronous cancellation.
 
-.. code-block: c++
+.. code-block:: c++
 
   pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
 

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 2c950231255d7f..cd1d298b0a8ff6 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -1858,7 +1858,8 @@ The attribute may be applied to the declaration of a 
class, a typedef, a
 variable, a function or method, a function parameter, an enumeration, an
 enumerator, a non-static data member, or a label.
 
-.. code-block: c++
+.. code-block:: c++
+
   #include 
 
   [[maybe_unused]] void f([[maybe_unused]] bool thing1,
@@ -1887,7 +1888,8 @@ literal contents) are allowed. If there are 
redeclarations of the entity with
 
diff ering string literals, it is unspecified which one will be used by Clang
 in any resulting diagnostics.
 
-.. code-block: c++
+.. code-block:: c++
+
   struct [[nodiscard]] error_info { /*...*/ };
   error_info enable_missile_safety_mode();
 
@@ -1904,7 +1906,8 @@ marked with ``[[nodiscard]]`` or a constructor of a type 
marked
 ``[[nodiscard]]`` will also diagnose. This also applies to type conversions 
that
 use the annotated ``[[nodiscard]]`` constructor or result in an annotated type.
 
-.. code-block: c++
+.. code-block:: c++
+
   struct [[nodiscard]] marked_type {/*..*/ };
   struct marked_ctor {
 [[nodiscard]] marked_ctor();
@@ -5685,12 +5688,12 @@ accessed. The following are examples of valid 
expressions where may not be diagn
 ``noderef`` is currently only supported for pointers and arrays and not usable
 for references or Objective-C object pointers.
 
-.. code-block: c++
+.. code-block:: c++
 
   int x = 2;
   int __attribute__((noderef)) &y = x;  // warning: 'noderef' can only be 

[clang] a82f35e - [OpenMP] Lower taskwait using OpenMP IR Builder

2020-02-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: Roger Ferrer Ibanez
Date: 2020-02-14T09:53:02Z
New Revision: a82f35e17621a036cb726244ee5cb9708545fb93

URL: 
https://github.com/llvm/llvm-project/commit/a82f35e17621a036cb726244ee5cb9708545fb93
DIFF: 
https://github.com/llvm/llvm-project/commit/a82f35e17621a036cb726244ee5cb9708545fb93.diff

LOG: [OpenMP] Lower taskwait using OpenMP IR Builder

The code generation is exactly the same as it was.

But not that the special handling of untied tasks is still handled by
emitUntiedSwitch in clang.

Differential Revision: https://reviews.llvm.org/D69828

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/task_codegen.cpp
clang/test/OpenMP/taskwait_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index fe672f346128..554d95a256ec 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6340,11 +6340,18 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction 
&CGF,
SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
 return;
-  // Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
-  // global_tid);
-  llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc)};
-  // Ignore return result until untied tasks are supported.
-  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskwait), Args);
+
+  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
+  if (OMPBuilder) {
+OMPBuilder->CreateTaskwait(CGF.Builder);
+  } else {
+// Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
+// global_tid);
+llvm::Value *Args[] = {emitUpdateLocation(CGF, Loc), getThreadID(CGF, 
Loc)};
+// Ignore return result until untied tasks are supported.
+CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskwait), 
Args);
+  }
+
   if (auto *Region = 
dyn_cast_or_null(CGF.CapturedStmtInfo))
 Region->emitUntiedSwitch(CGF);
 }

diff  --git a/clang/test/OpenMP/task_codegen.cpp 
b/clang/test/OpenMP/task_codegen.cpp
index cf9f03082563..47c31fb217ad 100644
--- a/clang/test/OpenMP/task_codegen.cpp
+++ b/clang/test/OpenMP/task_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o 
%t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp 
-fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-emit-pch -o %t %s

diff  --git a/clang/test/OpenMP/taskwait_codegen.cpp 
b/clang/test/OpenMP/taskwait_codegen.cpp
index 22f381b35199..20c332b3732b 100644
--- a/clang/test/OpenMP/taskwait_codegen.cpp
+++ b/clang/test/OpenMP/taskwait_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o 
%t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp 
-fopenmp-enable-irbuilder -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-emit-pch -o %t %s

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index a1470bc04958..c1ec28abd34c 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -176,6 +176,11 @@ class OpenMPIRBuilder {
   /// \param Loc The location where the fl

[clang] 2bef1c0 - [OpenMP] Lower taskyield using OpenMP IR Builder

2020-02-14 Thread Roger Ferrer Ibanez via cfe-commits
Author: Roger Ferrer Ibanez
Date: 2020-02-14T11:35:17Z
New Revision: 2bef1c0e5645639bda1807f7df970da97792b0c8

URL: 
https://github.com/llvm/llvm-project/commit/2bef1c0e5645639bda1807f7df970da97792b0c8
DIFF: 
https://github.com/llvm/llvm-project/commit/2bef1c0e5645639bda1807f7df970da97792b0c8.diff

LOG: [OpenMP] Lower taskyield using OpenMP IR Builder

This is similar to D69828.

Special codegen for enclosing untied tasks is still done in clang.

Differential Revision: https://reviews.llvm.org/D70799

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/taskyield_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 554d95a256ec..7440434df508 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3295,11 +3295,18 @@ void CGOpenMPRuntime::emitTaskyieldCall(CodeGenFunction 
&CGF,
 SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
 return;
-  // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
-  llvm::Value *Args[] = {
-  emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
-  llvm::ConstantInt::get(CGM.IntTy, /*V=*/0, /*isSigned=*/true)};
-  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskyield), Args);
+  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
+  if (OMPBuilder) {
+OMPBuilder->CreateTaskyield(CGF.Builder);
+  } else {
+// Build call __kmpc_omp_taskyield(loc, thread_id, 0);
+llvm::Value *Args[] = {
+emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
+llvm::ConstantInt::get(CGM.IntTy, /*V=*/0, /*isSigned=*/true)};
+CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskyield),
+Args);
+  }
+
   if (auto *Region = 
dyn_cast_or_null(CGF.CapturedStmtInfo))
 Region->emitUntiedSwitch(CGF);
 }

diff  --git a/clang/test/OpenMP/taskyield_codegen.cpp 
b/clang/test/OpenMP/taskyield_codegen.cpp
index d57071f48aa8..ce8a729771d7 100644
--- a/clang/test/OpenMP/taskyield_codegen.cpp
+++ b/clang/test/OpenMP/taskyield_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 
-triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple 
x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | 
FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -emit-pch -o %t %s

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index c1ec28abd34c..d0e9e40370bb 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -171,6 +171,7 @@ class OpenMPIRBuilder {
  Value *IfCondition, Value *NumThreads,
  omp::ProcBindKind ProcBind, bool IsCancellable);
 
+
   /// Generator for '#omp flush'
   ///
   /// \param Loc The location where the flush directive was encountered
@@ -181,6 +182,11 @@ class OpenMPIRBuilder {
   /// \param Loc The location where the taskwait directive was encountered.
   void CreateTaskwait(const LocationDescription& Loc);
 
+  /// Generator for '#omp taskyield'
+  ///
+  /// \param Loc The location where the taskyield directive was encountered.
+  void CreateTaskyield(const LocationDescription& Loc);
+
   ///}
 
 
@@ -251,6 +257,11 @@ class OpenMPIRBuilder {
   /// \param Loc The location at which the request originated and is fulfilled.
   void emitTaskwaitImpl(const LocationDescription &Loc);
 
+  /// Generate a taskyield runtime call.
+  ///
+  /// \param Loc The location at which the request originated and is fulfilled.
+  void emitTaskyieldImpl(const LocationDescription &Loc);
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def 
b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index 7d6f29ba2633..e0318ab3c551 1

[libcxx] r317210 - Mark tests as unsupported in C++98 as well

2017-11-02 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Nov  2 08:01:43 2017
New Revision: 317210

URL: http://llvm.org/viewvc/llvm-project?rev=317210&view=rev
Log:
Mark tests as unsupported in C++98 as well

Differential Revision: https://reviews.llvm.org/D38362


Modified:
libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp?rev=317210&r1=317209&r2=317210&view=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp (original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.match/exponential.pass.cpp Thu Nov  
2 08:01:43 2017
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: libcpp-no-exceptions
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++98, c++03
 
 // template 
 // bool

Modified: libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp?rev=317210&r1=317209&r2=317210&view=diff
==
--- libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp 
(original)
+++ libcxx/trunk/test/std/re/re.alg/re.alg.search/exponential.pass.cpp Thu Nov  
2 08:01:43 2017
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: libcpp-no-exceptions
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++98, c++03
 
 // template 
 // bool


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fa45f81 - [clang][Serialization][RISCV] Increase the number of reserved predefined type IDs

2023-06-19 Thread Roger Ferrer Ibanez via cfe-commits
Author: Roger Ferrer Ibanez
Date: 2023-06-19T14:37:46Z
New Revision: fa45f81ff7ea9fc2a2a40fea8dd7626ecc3a8dbb

URL: 
https://github.com/llvm/llvm-project/commit/fa45f81ff7ea9fc2a2a40fea8dd7626ecc3a8dbb
DIFF: 
https://github.com/llvm/llvm-project/commit/fa45f81ff7ea9fc2a2a40fea8dd7626ecc3a8dbb.diff

LOG: [clang][Serialization][RISCV] Increase the number of reserved predefined 
type IDs

In D152070 we added many new intrinsic types required for the RISC-V
Vector Extension.

This was crashing when loading the AST as those types are intrinsically
added to the AST (they don't come from the disk).

The total number required now by clang exceeds 400 so increasing the
value to 500 solves the problem. This value was already increased in
D92715 but I assume this has some impact on the on-disk format.

Also add a static assert to avoid this happening again in the future.

Differential Revision: https://reviews.llvm.org/D153111

Added: 


Modified: 
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/Serialization/ASTReader.cpp
clang/test/Modules/embed-files-compressed.cpp
clang/test/Modules/empty.modulemap

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index a93eb3d38a480..7019bc5922ebc 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1099,6 +1099,8 @@ enum PredefinedTypeIDs {
 // \brief WebAssembly reference types with auto numeration
 #define WASM_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID,
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
+  // Sentinel value. Considered a predefined type but not useable as one.
+  PREDEF_TYPE_LAST_ID
 };
 
 /// The number of predefined type IDs that are reserved for
@@ -1106,7 +1108,13 @@ enum PredefinedTypeIDs {
 ///
 /// Type IDs for non-predefined types will start at
 /// NUM_PREDEF_TYPE_IDs.
-const unsigned NUM_PREDEF_TYPE_IDS = 300;
+const unsigned NUM_PREDEF_TYPE_IDS = 500;
+
+// Ensure we do not overrun the predefined types we reserved
+// in the enum PredefinedTypeIDs above.
+static_assert(PREDEF_TYPE_LAST_ID < NUM_PREDEF_TYPE_IDS,
+  "Too many enumerators in PredefinedTypeIDs. Review the value of "
+  "NUM_PREDEF_TYPE_IDS");
 
 /// Record codes for each kind of type.
 ///

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index a0ccc5aa4a741..cba6791783e8b 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -6983,6 +6983,10 @@ QualType ASTReader::GetType(TypeID ID) {
   if (Index < NUM_PREDEF_TYPE_IDS) {
 QualType T;
 switch ((PredefinedTypeIDs)Index) {
+case PREDEF_TYPE_LAST_ID:
+  // We should never use this one.
+  llvm_unreachable("Invalid predefined type");
+  break;
 case PREDEF_TYPE_NULL_ID:
   return QualType();
 case PREDEF_TYPE_VOID_ID:

diff  --git a/clang/test/Modules/embed-files-compressed.cpp 
b/clang/test/Modules/embed-files-compressed.cpp
index ae016bc1f9630..873b3082a2fdf 100644
--- a/clang/test/Modules/embed-files-compressed.cpp
+++ b/clang/test/Modules/embed-files-compressed.cpp
@@ -17,7 +17,7 @@
 // RUN: %clang_cc1 -fmodules -I%t -fmodules-cache-path=%t -fmodule-name=a 
-emit-module %t/modulemap -fmodules-embed-all-files -o %t/a.pcm
 //
 // The above embeds ~4.5MB of highly-predictable /s and \ns into the pcm file.
-// Check that the resulting file is under 40KB:
+// Check that the resulting file is under 60KB:
 //
 // RUN: wc -c %t/a.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[123][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}

diff  --git a/clang/test/Modules/empty.modulemap 
b/clang/test/Modules/empty.modulemap
index 3225d88829ae0..f2d37c19d77bc 100644
--- a/clang/test/Modules/empty.modulemap
+++ b/clang/test/Modules/empty.modulemap
@@ -13,8 +13,8 @@
 // The module file should be identical each time we produce it.
 // RUN: 
diff  %t/base.pcm %t/check.pcm
 //
-// We expect an empty module to be less than 40KB (and at least 10K, for now).
+// We expect an empty module to be less than 60KB (and at least 10K, for now).
 // RUN: wc -c %t/base.pcm | FileCheck --check-prefix=CHECK-SIZE %s
-// CHECK-SIZE: {{(^|[^0-9])[123][0-9][0-9][0-9][0-9]($|[^0-9])}}
+// CHECK-SIZE: {{(^|[^0-9])[1-5][0-9][0-9][0-9][0-9]($|[^0-9])}}
 
 module empty { header "Inputs/empty.h" export * }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291550 - Mark tests as unsupported under libcpp-no-exceptions

2017-01-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Jan 10 02:48:48 2017
New Revision: 291550

URL: http://llvm.org/viewvc/llvm-project?rev=291550&view=rev
Log:
Mark tests as unsupported under libcpp-no-exceptions

The destructor of std::promise needs to construct a std::future_error
exception so it calls std::make_exception_ptr. But under
libcpp-no-exceptions this will trigger an abort.

Differential Revision: https://reviews.llvm.org/D27614


Modified:
libcxx/trunk/test/std/thread/futures/futures.shared_future/dtor.pass.cpp
libcxx/trunk/test/std/thread/futures/futures.unique_future/dtor.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/futures/futures.shared_future/dtor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.shared_future/dtor.pass.cpp?rev=291550&r1=291549&r2=291550&view=diff
==
--- libcxx/trunk/test/std/thread/futures/futures.shared_future/dtor.pass.cpp 
(original)
+++ libcxx/trunk/test/std/thread/futures/futures.shared_future/dtor.pass.cpp 
Tue Jan 10 02:48:48 2017
@@ -7,7 +7,7 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 

Modified: 
libcxx/trunk/test/std/thread/futures/futures.unique_future/dtor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.unique_future/dtor.pass.cpp?rev=291550&r1=291549&r2=291550&view=diff
==
--- libcxx/trunk/test/std/thread/futures/futures.unique_future/dtor.pass.cpp 
(original)
+++ libcxx/trunk/test/std/thread/futures/futures.unique_future/dtor.pass.cpp 
Tue Jan 10 02:48:48 2017
@@ -7,7 +7,7 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r278908 - Add missing tests

2016-08-17 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Aug 17 01:52:15 2016
New Revision: 278908

URL: http://llvm.org/viewvc/llvm-project?rev=278908&view=rev
Log:
Add missing tests

Change r278483 was missing the tests

Differential Revision: https://reviews.llvm.org/D20561


Added:
cfe/trunk/test/Sema/address-packed-member-memops.c
cfe/trunk/test/Sema/address-packed.c
cfe/trunk/test/SemaCXX/address-packed-member-memops.cpp
cfe/trunk/test/SemaCXX/address-packed.cpp

Added: cfe/trunk/test/Sema/address-packed-member-memops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address-packed-member-memops.c?rev=278908&view=auto
==
--- cfe/trunk/test/Sema/address-packed-member-memops.c (added)
+++ cfe/trunk/test/Sema/address-packed-member-memops.c Wed Aug 17 01:52:15 2016
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct B {
+  int x, y, z, w;
+} b;
+
+struct __attribute__((packed)) A {
+  struct B b;
+} a;
+
+typedef __typeof__(sizeof(int)) size_t;
+
+void *memcpy(void *dest, const void *src, size_t n);
+int memcmp(const void *s1, const void *s2, size_t n);
+void *memmove(void *dest, const void *src, size_t n);
+void *memset(void *s, int c, size_t n);
+
+int x;
+
+void foo(void) {
+  memcpy(&a.b, &b, sizeof(b));
+  memmove(&a.b, &b, sizeof(b));
+  memset(&a.b, 0, sizeof(b));
+  x = memcmp(&a.b, &b, sizeof(b));
+}

Added: cfe/trunk/test/Sema/address-packed.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address-packed.c?rev=278908&view=auto
==
--- cfe/trunk/test/Sema/address-packed.c (added)
+++ cfe/trunk/test/Sema/address-packed.c Wed Aug 17 01:52:15 2016
@@ -0,0 +1,163 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include 
+
+extern void f1(int *);
+extern void f2(char *);
+
+struct Ok {
+  char c;
+  int x;
+};
+
+struct __attribute__((packed)) Arguable {
+  char c0;
+  int x;
+  char c1;
+};
+
+union __attribute__((packed)) UnionArguable {
+  char c;
+  int x;
+};
+
+typedef struct Arguable ArguableT;
+
+struct Arguable *get_arguable();
+
+void to_void(void *);
+
+void g0(void) {
+  {
+struct Ok ok;
+f1(&ok.x); // no-warning
+f2(&ok.c); // no-warning
+  }
+  {
+struct Arguable arguable;
+f2(&arguable.c0); // no-warning
+f1(&arguable.x);  // expected-warning {{packed member 'x' of class or 
structure 'Arguable'}}
+f2(&arguable.c1); // no-warning
+
+f1((int *)(void *)&arguable.x); // no-warning
+to_void(&arguable.x);   // no-warning
+void *p = &arguable.x;  // no-warning;
+to_void(p);
+  }
+  {
+union UnionArguable arguable;
+f2(&arguable.c); // no-warning
+f1(&arguable.x); // expected-warning {{packed member 'x' of class or 
structure 'UnionArguable'}}
+
+f1((int *)(void *)&arguable.x); // no-warning
+to_void(&arguable.x);   // no-warning
+  }
+  {
+ArguableT arguable;
+f2(&arguable.c0); // no-warning
+f1(&arguable.x);  // expected-warning {{packed member 'x' of class or 
structure 'Arguable'}}
+f2(&arguable.c1); // no-warning
+
+f1((int *)(void *)&arguable.x); // no-warning
+to_void(&arguable.x);   // no-warning
+  }
+  {
+struct Arguable *arguable = get_arguable();
+f2(&arguable->c0); // no-warning
+f1(&arguable->x);  // expected-warning {{packed member 'x' of class or 
structure 'Arguable'}}
+f2(&arguable->c1); // no-warning
+
+f1((int *)(void *)&arguable->x); // no-warning
+to_void(&arguable->c1);  // no-warning
+  }
+  {
+ArguableT *arguable = get_arguable();
+f2(&(arguable->c0)); // no-warning
+f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or 
structure 'Arguable'}}
+f2(&(arguable->c1)); // no-warning
+
+f1((int *)(void *)&(arguable->x)); // no-warning
+to_void(&(arguable->c1));  // no-warning
+  }
+}
+
+struct S1 {
+  char c;
+  int i __attribute__((packed));
+};
+
+int *g1(struct S1 *s1) {
+  return &s1->i; // expected-warning {{packed member 'i' of class or structure 
'S1'}}
+}
+
+struct S2_i {
+  int i;
+};
+struct __attribute__((packed)) S2 {
+  char c;
+  struct S2_i inner;
+};
+
+int *g2(struct S2 *s2) {
+  return &s2->inner.i; // expected-warning {{packed member 'inner' of class or 
structure 'S2'}}
+}
+
+struct S2_a {
+  char c;
+  struct S2_i inner __attribute__((packed));
+};
+
+int *g2_a(struct S2_a *s2_a) {
+  return &s2_a->inner.i; // expected-warning {{packed member 'inner' of class 
or structure 'S2_a'}}
+}
+
+struct __attribute__((packed)) S3 {
+  char c;
+  struct {
+int i;
+  } inner;
+};
+
+int *g3(struct S3 *s3) {
+  return &s3->inner.i; // expected-warning {{packed member 'inner' of class or 
structure 'S3'}}
+}
+
+struct S4 {
+  char c;
+  struct __attribute__((packed)) {
+int i;
+  } inner;
+};
+
+int *g4(struct S4 *s4) {
+  return &s4->inner.i; /

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-08-18 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: aaron.ballman, rsmith.
rogfer01 added a subscriber: cfe-commits.

This change remove some false positives when taking the address of packed 
members.

- It silences the warning when a cast to uintptr_t/intptr_t happens.
- If the field is in a packed record that is overaligned, the field may still 
be in a suitable offset for the required alignment of the field. We now check 
this as well.

https://reviews.llvm.org/D23657

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,18 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void foo()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11016,43 +11016,55 @@
 }
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
-  if (!T->isPointerType())
+  if (!T->isPointerType() && !T->isIntegerType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
   auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
   MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)
+  (T->isIntegerType() ||
+   (T->isPointerType() &&
+Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)))
 MisalignedMembers.erase(MA);
 }
   }
 }
 
 void Sema::RefersToMemberWithReducedAlignment(
 Expr *E,
 std::function Action) {
+  // return;
   const auto *ME = dyn_cast(E);
+  CharUnits RequiredAlignment;
   while (ME && isa(ME->getMemberDecl())) {
 QualType BaseType = ME->getBase()->getType();
 if (ME->isArrow())
   BaseType = BaseType->getPointeeType();
 RecordDecl *RD = BaseType->getAs()->getDecl();
 
 ValueDecl *MD = ME->getMemberDecl();
-bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
-if (ByteAligned) // Attribute packed does not have any effect.
-  break;
+a

RE: r278483 - This patch implements PR#22821.

2016-08-23 Thread Roger Ferrer Ibanez via cfe-commits
Yes it was approved on IRC by Aaron Ballman:

T 1470758009  zygoloid: do you have any further thoughts about 
https://reviews.llvm.org/D20561 ? thank you very much :)
T 1470758207  rogfer01: if zygoloid doesn't review in the 
next two days, you can go ahead and commit. I've accepted it, and Richard's 
comments suggest you're following the correct approach with your latest patch. 
If there are problems, we can always revert again if needed

Kind regards,
Roger

From: tha...@google.com [mailto:tha...@google.com] On Behalf Of Nico Weber
Sent: 22 August 2016 17:59
To: Roger Ferrer Ibanez
Cc: cfe-commits
Subject: Re: r278483 - This patch implements PR#22821.

I don't see any approval after Aaron's "Please wait until someone has had the 
chance to review before committing" on https://reviews.llvm.org/D20561 -- was 
this reviewed on IRC?

On Fri, Aug 12, 2016 at 4:04 AM, Roger Ferrer Ibanez via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: rogfer01
Date: Fri Aug 12 03:04:13 2016
New Revision: 278483

URL: http://llvm.org/viewvc/llvm-project?rev=278483&view=rev
Log:
This patch implements PR#22821.

Taking the address of a packed member is dangerous since the reduced
alignment of the pointee is lost. This can lead to memory alignment
faults in some architectures if the pointer value is dereferenced.

This change adds a new warning to clang emitted when taking the address
of a packed member. A packed member is either a field/data member
declared as attribute((packed)) or belonging to a struct/class
declared as such. The associated flag is -Waddress-of-packed-member.
Conversions (either implicit or via a valid casting) to pointer types
with lower or equal alignment requirements (e.g. void* or char*)
will silence the warning.

Differential Revision: https://reviews.llvm.org/D20561



Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=278483&r1=278482&r2=278483&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 12 03:04:13 
2016
@@ -5489,6 +5489,9 @@ def warn_pointer_indirection_from_incomp
   "dereference of type %1 that was reinterpret_cast from type %0 has undefined 
"
   "behavior">,
   InGroup, DefaultIgnore;
+def warn_taking_address_of_packed_member : Warning<
+  "taking address of packed member %0 of class or structure %q1 may result in 
an unaligned pointer value">,
+  InGroup>;

 def err_objc_object_assignment : Error<
   "cannot assign to class object (%0 invalid)">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=278483&r1=278482&r2=278483&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Aug 12 03:04:13 2016
@@ -9570,6 +9570,10 @@ private:
   void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
 const Expr * const *ExprArgs);

+  /// \brief Check if we are taking the address of a packed field
+  /// as this may be a problem if the pointer value is dereferenced.
+  void CheckAddressOfPackedMember(Expr *rhs);
+
   /// \brief The parser's current scope.
   ///
   /// The parser maintains this state here.
@@ -9664,6 +9668,51 @@ public:
   // Emitting members of dllexported classes is delayed until the class
   // (including field initializers) is fully parsed.
   SmallVector DelayedDllExportClasses;
+
+private:
+  /// \brief Helper class that collects misaligned member designations and
+  /// their location info for delayed diagnostics.
+  struct MisalignedMember {
+Expr *E;
+RecordDecl *RD;
+ValueDecl *MD;
+CharUnits Alignment;
+
+MisalignedMember() : E(), RD(), MD(), Alignment() {}
+MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
+ CharUnits Alignment)
+: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
+explicit MisalignedMember(Expr *E)
+: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
+
+bool operator==(const MisalignedMember &m) { return this->E == m.E; }
+  };
+  /// \brief Small set of gathered accesses to potentially misaligned members
+  /// due to the packed attribute.
+  SmallVector MisalignedMembers;
+
+  /// \brief Adds an expression to the set of gathered misaligned 

Re: [PATCH] D23657: Remove some false positives when taking the address of packed members

2016-08-23 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Hi, this is a friendly ping.

Thank you! :)


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23657: Remove some false positives when taking the address of packed members

2016-09-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 69968.
rogfer01 added a comment.

Skip the check if the field is already aligned to 1.


https://reviews.llvm.org/D23657

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,18 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void foo()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11016,16 +11016,18 @@
 }
 
 void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) {
-  if (!T->isPointerType())
+  if (!T->isPointerType() && !T->isIntegerType())
 return;
   if (isa(E) &&
   cast(E)->getOpcode() == UO_AddrOf) {
 auto *Op = cast(E)->getSubExpr()->IgnoreParens();
 if (isa(Op)) {
   auto MA = std::find(MisalignedMembers.begin(), MisalignedMembers.end(),
   MisalignedMember(Op));
   if (MA != MisalignedMembers.end() &&
-  Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)
+  (T->isIntegerType() ||
+   (T->isPointerType() &&
+Context.getTypeAlignInChars(T->getPointeeType()) <= MA->Alignment)))
 MisalignedMembers.erase(MA);
 }
   }
@@ -11035,25 +11037,38 @@
 Expr *E,
 std::function Action) {
   const auto *ME = dyn_cast(E);
+  CharUnits RequiredAlignment;
   while (ME && isa(ME->getMemberDecl())) {
 QualType BaseType = ME->getBase()->getType();
 if (ME->isArrow())
   BaseType = BaseType->getPointeeType();
 RecordDecl *RD = BaseType->getAs()->getDecl();
 
 ValueDecl *MD = ME->getMemberDecl();
-bool ByteAligned = Context.getTypeAlignInChars(MD->getType()).isOne();
-if (ByteAligned) // Attribute packed does not have any effect.
-  break;
+CharUnits AlignField = Context.getTypeAlignInChars(MD->getType());
 
-if (!ByteAligned &&
-(RD->hasAttr() || (MD->hasAttr( {
-  CharUnits Alignment = std::min(Context.getTypeAlignInChars(MD->getType()),
- Context.getTypeAlignInChars(BaseType));
-  // Notify that this expression designates a member with r

Re: [PATCH] D23657: Remove some false positives when taking the address of packed members

2016-09-07 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping? :)

Thank you very much.


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23657: Remove some false positives when taking the address of packed members

2016-09-16 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

This is a friendly ping :)

Thank you very much!


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296099 - Fix crash when an incorrect redeclaration only differs in __unaligned type-qualifier

2017-02-24 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Fri Feb 24 02:41:09 2017
New Revision: 296099

URL: http://llvm.org/viewvc/llvm-project?rev=296099&view=rev
Log:
Fix crash when an incorrect redeclaration only differs in __unaligned 
type-qualifier

Fix an assertion that is hit when a redeclaration with differing types only
differs in the unaligned type-qualifier.

Differential Revision: https://reviews.llvm.org/D29986


Added:
cfe/trunk/test/Sema/unaligned-qualifier.c
Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=296099&r1=296098&r2=296099&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Feb 24 02:41:09 2017
@@ -8077,7 +8077,8 @@ QualType ASTContext::mergeTypes(QualType
 // mismatch.
 if (LQuals.getCVRQualifiers() != RQuals.getCVRQualifiers() ||
 LQuals.getAddressSpace() != RQuals.getAddressSpace() ||
-LQuals.getObjCLifetime() != RQuals.getObjCLifetime())
+LQuals.getObjCLifetime() != RQuals.getObjCLifetime() ||
+LQuals.hasUnaligned() != RQuals.hasUnaligned())
   return QualType();
 
 // Exactly one GC qualifier difference is allowed: __strong is

Added: cfe/trunk/test/Sema/unaligned-qualifier.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/unaligned-qualifier.c?rev=296099&view=auto
==
--- cfe/trunk/test/Sema/unaligned-qualifier.c (added)
+++ cfe/trunk/test/Sema/unaligned-qualifier.c Fri Feb 24 02:41:09 2017
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fms-extensions
+
+int __unaligned * p1; // expected-note {{previous definition is here}}
+int * p1; // expected-error {{redefinition of 'p1' with a different type: 'int 
*' vs '__unaligned int *'}}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r297276 - Honor __unaligned in codegen for declarations and expressions

2017-03-08 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Mar  8 08:00:44 2017
New Revision: 297276

URL: http://llvm.org/viewvc/llvm-project?rev=297276&view=rev
Log:
Honor __unaligned in codegen for declarations and expressions

This patch honors the unaligned type qualifier (currently available through he
keyword __unaligned and -fms-extensions) in CodeGen. In the current form the
patch affects declarations and expressions. It does not affect fields of
classes.

Differential Revision: https://reviews.llvm.org/D30166


Added:
cfe/trunk/test/CodeGen/unaligned-decl.c
cfe/trunk/test/CodeGen/unaligned-expr.c
cfe/trunk/test/CodeGen/unaligned-field.c
cfe/trunk/test/CodeGenCXX/unaligned.cpp
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=297276&r1=297275&r2=297276&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Mar  8 08:00:44 2017
@@ -1473,6 +1473,8 @@ CharUnits ASTContext::getDeclAlign(const
 }
   }
   Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
+  if (BaseT.getQualifiers().hasUnaligned())
+Align = Target->getCharWidth();
   if (const VarDecl *VD = dyn_cast(D)) {
 if (VD->hasGlobalStorage() && !ForAlignof)
   Align = std::max(Align, getTargetInfo().getMinGlobalAlign());

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=297276&r1=297275&r2=297276&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Wed Mar  8 08:00:44 2017
@@ -5677,6 +5677,8 @@ static CharUnits GetAlignOfType(EvalInfo
 T = Ref->getPointeeType();
 
   // __alignof is defined to return the preferred alignment.
+  if (T.getQualifiers().hasUnaligned())
+return CharUnits::One();
   return Info.Ctx.toCharUnitsFromBits(
 Info.Ctx.getPreferredTypeAlign(T.getTypePtr()));
 }

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=297276&r1=297275&r2=297276&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Mar  8 08:00:44 2017
@@ -149,6 +149,8 @@ CharUnits CodeGenFunction::getNaturalTyp
   Alignment = CGM.getClassPointerAlignment(RD);
 } else {
   Alignment = getContext().getTypeAlignInChars(T);
+  if (T.getQualifiers().hasUnaligned())
+Alignment = CharUnits::One();
 }
 
 // Cap to the global maximum type alignment unless the alignment

Added: cfe/trunk/test/CodeGen/unaligned-decl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/unaligned-decl.c?rev=297276&view=auto
==
--- cfe/trunk/test/CodeGen/unaligned-decl.c (added)
+++ cfe/trunk/test/CodeGen/unaligned-decl.c Wed Mar  8 08:00:44 2017
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm 
< %s | FileCheck %s
+
+// CHECK: @a1 = global i32 1, align 1
+__unaligned int a1 = 1;
+
+// CHECK: @a2 = global i32 1, align 1
+int __unaligned a2 = 1;
+
+// CHECK: @a3 = {{.*}} align 1
+__unaligned int a3[10];
+
+// CHECK: @a4 = {{.*}} align 1
+int __unaligned a4[10];
+
+// CHECK: @p1 = {{.*}} align 1
+int *__unaligned p1;
+
+// CHECK: @p2 = {{.*}} align 8
+int __unaligned *p2;
+
+// CHECK: @p3 = {{.*}} align 1
+int __unaligned *__unaligned p3;

Added: cfe/trunk/test/CodeGen/unaligned-expr.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/unaligned-expr.c?rev=297276&view=auto
==
--- cfe/trunk/test/CodeGen/unaligned-expr.c (added)
+++ cfe/trunk/test/CodeGen/unaligned-expr.c Wed Mar  8 08:00:44 2017
@@ -0,0 +1,217 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fms-extensions -emit-llvm 
< %s | FileCheck %s
+
+// -
+// Scalar integer
+// -
+__unaligned int x;
+void test1(void) {
+  // CHECK: {{%.*}} = load i32, i32* @x, align 1
+  // CHECK: store i32 {{%.*}}, i32* @x, align 1
+  x++;
+}
+
+void test2(void) {
+  // CHECK: %y = alloca i32, align 1
+  // CHECK: {{%.*}} = load i32, i32* %y, align 1
+  // CHECK: store i32 {{%.*}}, i32* %y, align 1
+  __unaligned int y;
+  y++;
+}
+
+void test2_1(void) {
+  // CHECK: %y = alloca i32, align 1
+  // CHECK: store i32 1, i32* %y, align 1
+  __unaligned int y = 1;
+}
+
+// -
+// Global pointer
+// -
+int *__unaligned p1;
+void test3(void) {
+
+  //

r297620 - When diagnosing taking address of packed members skip __unaligned-qualified expressions

2017-03-13 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Mar 13 08:18:21 2017
New Revision: 297620

URL: http://llvm.org/viewvc/llvm-project?rev=297620&view=rev
Log:
When diagnosing taking address of packed members skip __unaligned-qualified 
expressions

Given that we have already explicitly stated in the qualifier that the
expression is __unaligned, it makes little sense to diagnose that the address
of the packed member may not be aligned.

Differential Revision: https://reviews.llvm.org/D30884


Added:
cfe/trunk/test/Sema/address-unaligned.c
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=297620&r1=297619&r2=297620&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Mar 13 08:18:21 2017
@@ -11851,6 +11851,10 @@ void Sema::RefersToMemberWithReducedAlig
   if (!ME)
 return;
 
+  // No need to check expressions with an __unaligned-qualified type.
+  if (E->getType().getQualifiers().hasUnaligned())
+return;
+
   // For a chain of MemberExpr like "a.b.c.d" this list
   // will keep FieldDecl's like [d, c, b].
   SmallVector ReverseMemberChain;

Added: cfe/trunk/test/Sema/address-unaligned.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/address-unaligned.c?rev=297620&view=auto
==
--- cfe/trunk/test/Sema/address-unaligned.c (added)
+++ cfe/trunk/test/Sema/address-unaligned.c Mon Mar 13 08:18:21 2017
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify %s
+// expected-no-diagnostics
+
+typedef
+struct __attribute__((packed)) S1 {
+  char c0;
+  int x;
+  char c1;
+} S1;
+
+void bar(__unaligned int *);
+
+void foo(__unaligned S1* s1)
+{
+bar(&s1->x);
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26612: Protect std::string tests under libcpp-no-exceptions

2016-11-15 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 78012.
rogfer01 added a comment.

Restructure to minimize code duplication.


https://reviews.llvm.org/D26612

Files:
  test/std/strings/basic.string/string.capacity/capacity.pass.cpp
  test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp


Index: test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -24,19 +23,29 @@
 void
 test(const S& s, typename S::size_type pos, typename S::size_type n)
 {
-try
+if (pos <= s.size())
 {
 S str = s.substr(pos, n);
 LIBCPP_ASSERT(str.__invariants());
 assert(pos <= s.size());
 typename S::size_type rlen = std::min(n, s.size() - pos);
 assert(str.size() == rlen);
 assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
 }
-catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos > s.size());
+try
+{
+S str = s.substr(pos, n);
+assert(false);
+}
+catch (std::out_of_range&)
+{
+assert(pos > s.size());
+}
 }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.capacity/capacity.pass.cpp
===
--- test/std/strings/basic.string/string.capacity/capacity.pass.cpp
+++ test/std/strings/basic.string/string.capacity/capacity.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // size_type capacity() const;
@@ -18,21 +17,27 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template 
 void
 test(S s)
 {
 S::allocator_type::throw_after = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 while (s.size() < s.capacity())
 s.push_back(typename S::value_type());
 assert(s.size() == s.capacity());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 S::allocator_type::throw_after = INT_MAX;
 }
 


Index: test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -24,19 +23,29 @@
 void
 test(const S& s, typename S::size_type pos, typename S::size_type n)
 {
-try
+if (pos <= s.size())
 {
 S str = s.substr(pos, n);
 LIBCPP_ASSERT(str.__invariants());
 assert(pos <= s.size());
 typename S::size_type rlen = std::min(n, s.size() - pos);
 assert(str.size() == rlen);
 assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
 }
-catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos > s.size());
+try
+{
+S str = s.substr(pos, n);
+assert(false);
+}
+catch (std::out_of_range&)
+{
+assert(pos > s.size());
+}
 }
+#endif
 }
 
 int main()
Index: test/std/strings/basic.string/string.capacity/capacity.pass.cpp
===
--- test/std/strings/basic.string/string.capacity/capacity.pass.cpp
+++ test/std/strings/basic.string/string.capacity/capacity.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // size_type capacity() const;
@@ -18,21 +17,27 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template 
 void
 test(S s)
 {
 S::allocator_type::throw_after = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 while (s.size() < s.capacity())
 s.push_back(typename S::value_type());
 assert(s.size() == s.capacity());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 S::allocator_type::throw_after = INT_MAX;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-comm

[PATCH] D23325: [WIP] Binding of references to packed fields

2016-11-16 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added inline comments.



Comment at: include/clang/Basic/Specifiers.h:119-140
   enum ExprObjectKind {
 /// An ordinary object is located at an address in memory.
 OK_Ordinary,
 
 /// A bitfield object is a bitfield on a C or C++ record.
 OK_BitField,
 

rsmith wrote:
> Wait a second, how did this fit into 2 bits before your change?!
It didn't.

I was also really confused when some unrelated Obj-C tests started failing 
after this change.


https://reviews.llvm.org/D23325



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23325: [WIP] Binding of references to packed fields

2016-11-16 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 marked 15 inline comments as done.
rogfer01 added a comment.

I am retaking this, will upload an updated patch soon.




Comment at: lib/AST/Decl.cpp:3523
+  return !isBitField() &&
+ (this->hasAttr() || getParent()->hasAttr()) &&
+ Context.getDeclAlign(this) <

rsmith wrote:
> Does this properly handle anonymous struct/union members:
> 
>   struct A __attribute__((packed)) {
> char a;
> union { int b; };
>   } a;
>   int &r = a.b;
This test (modulo swapping `A` and `__attribute__((packed))`  positions) works. 
Do you think we may be missing some case here?



Comment at: test/SemaCXX/bind-packed-member.cpp:68-73
+struct F
+{
+char c;
+NonTrivialCopy x __attribute__((packed));
+int w __attribute__((packed));
+} f;

rsmith wrote:
> Another interesting case:
> 
> struct __attribute__((packed)) G {
>   char c;
>   NonTrivialCopy x;
> };
> 
> Here, GCC ignores the `packed` attribute entirely (with a warning). For ABI 
> compatibility, we should do the same.
Will do this in a later update of this patch.

I still have to check what is the best place to check this, though I think once 
the class-specifier has been completed.


https://reviews.llvm.org/D23325



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23325: [WIP] Binding of references to packed fields

2016-11-16 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 78209.
rogfer01 added a comment.

Changes:

- Rebase patch to trunk
- Fixes as pointed out by reviewers

TODO:

- Diagnose and drop the packed attribute of a class with a nontrivially 
constructed data member.


https://reviews.llvm.org/D23325

Files:
  include/clang/AST/Decl.h
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  lib/AST/ASTDumper.cpp
  lib/AST/Decl.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaFixItUtils.cpp
  lib/Sema/SemaInit.cpp
  test/SemaCXX/bind-packed-member.cpp

Index: test/SemaCXX/bind-packed-member.cpp
===
--- test/SemaCXX/bind-packed-member.cpp
+++ test/SemaCXX/bind-packed-member.cpp
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -verify %s
+
+struct __attribute__((packed)) A {
+  char x;
+  float y;
+  char z;
+} a;
+
+char &rax = a.x;  // no-error
+float &ray = a.y; // expected-error {{reference cannot bind to packed field}}
+char &raz = a.z;  // no-error
+
+struct __attribute__((packed, aligned(2))) B {
+  // Regardless of aligned(2) the fields are aligned(1) because of packed.
+  // The whole struct is aligned(2), though.
+  short x;
+  float y;
+  short z;
+  char w;
+} b;
+
+const short &crbx = b.x; // no-error
+short &rbx = b.x; // expected-error {{reference cannot bind to packed field}}
+float &rby = b.y; // expected-error {{reference cannot bind to packed field}}
+short &rbz = b.z; // expected-error {{reference cannot bind to packed field}}
+char &rbw = b.w;  // no-error
+
+struct __attribute__((packed)) B2 {
+  short x __attribute__((aligned(2)));
+  float y;
+  short z __attribute__((aligned(4)));
+  char w;
+} b2;
+
+short &rb2x = b2.x; // no-error
+short &rb2z = b2.z; // no-error
+
+struct C {
+  int c;
+};
+
+struct __attribute__((packed)) D {
+  char x;
+  int y;
+  C z;
+} d;
+
+C &rcz = d.z; // expected-error {{reference cannot bind to packed field}}
+int &rczc = d.z.c; // expected-error {{reference cannot bind to packed field}}
+
+struct E {
+int x __attribute__((packed));
+C y __attribute__((packed));
+C z;
+} e;
+
+int& rex = e.x; // expected-error {{reference cannot bind to packed field}}
+C& rey = e.y; // expected-error {{reference cannot bind to packed field}}
+C& rez = e.z;  // no-error
+
+struct NonTrivialCopy
+{
+int w;
+NonTrivialCopy();
+NonTrivialCopy(const NonTrivialCopy&);
+};
+
+struct F
+{
+char c;
+NonTrivialCopy x __attribute__((packed));
+int w __attribute__((packed));
+} f;
+
+
+void fun1(int &);
+void fun2(const int &);
+
+void bar()
+{
+const NonTrivialCopy& rx = f.x; // expected-error {{reference cannot bind to packed field}}
+const int &w = f.w; // no-error
+
+fun1(f.w); // expected-error {{reference cannot bind to packed field}}
+   // expected-note@76 {{passing argument to parameter here}}
+fun2(f.w); // no-error
+}
+
+struct __attribute__((packed)) Z {
+  char z;
+  union { int b; };
+} z;
+int &rzb = z.b; // expected-error {{reference cannot bind to packed field}}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -4200,6 +4200,7 @@
  Qualifiers T2Quals,
  bool IsLValueRef) {
   bool IsNonAddressableType = Initializer->refersToBitField() ||
+  Initializer->refersToPackedField() ||
   Initializer->refersToVectorElement();
 
   if (IsNonAddressableType) {
@@ -4214,6 +4215,31 @@
   return Initializer->getValueKind();
 }
 
+if (Initializer->refersToPackedField() &&
+Initializer->getType()->getAsCXXRecordDecl()) {
+  auto Record = Initializer->getType()->getAsCXXRecordDecl();
+  /*
+Consider the case below:
+   struct A
+   {
+   char c;
+   std::vector x __attribute__((packed));
+   } a;
+
+   void f()
+   {
+   const std::vector& w = a.x;
+   }
+
+If the class doesn't have a trivial copy constructor, we can't create
+a copy of it for the reference binding because doing so would bind it to
+a reference in the class's own copy/move constructor, so just give up
+and allow the error to be diagnosed.
+  */
+  if (!Record->hasTrivialCopyConstructor())
+return Initializer->getValueKind();
+}
+
 // Force a load so we can materialize a temporary.
 Sequence.AddLValueToRValueStep(cv1T1.getUnqualifiedType());
 return VK_RValue;
@@ -6445,6 +6471,13 @@
 return ExprError();
   }
 
+  if (CurInit.get()->refersToPackedField()) {
+S.Diag(Kind.getLocation(), diag::err_reference_bind_to_packed_field)
+<< CurInit.get()->get

[PATCH] D26606: Protect tests for std::uninitialized_{copy, fill} under libcpp-no-exceptions

2016-11-21 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping? :)


https://reviews.llvm.org/D26606



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26611: Protect test for dynarray under libcpp-no-exceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?


https://reviews.llvm.org/D26611



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26612: Protect std::string tests under libcpp-no-exceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?


https://reviews.llvm.org/D26612



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26608: Protect std::string tests under libcpp-no-exceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287865: Protect std::string tests under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26608?vs=77805&id=79206#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26608

Files:
  libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp


Index: 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
===
--- 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
+++ 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -24,19 +23,27 @@
 void
 test(const S& s, typename S::size_type pos, typename S::size_type n)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#else
+if (pos <= s.size())
+#endif
 {
 S str = s.substr(pos, n);
 LIBCPP_ASSERT(str.__invariants());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(pos <= s.size());
+#endif
 typename S::size_type rlen = std::min(n, s.size() - pos);
 assert(str.size() == rlen);
 assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (std::out_of_range&)
 {
 assert(pos > s.size());
 }
+#endif
 }
 
 int main()
Index: 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
===
--- libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
+++ libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // size_type capacity() const;
@@ -18,21 +17,27 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template 
 void
 test(S s)
 {
 S::allocator_type::throw_after = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 while (s.size() < s.capacity())
 s.push_back(typename S::value_type());
 assert(s.size() == s.capacity());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 S::allocator_type::throw_after = INT_MAX;
 }
 


Index: libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
===
--- libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
+++ libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -24,19 +23,27 @@
 void
 test(const S& s, typename S::size_type pos, typename S::size_type n)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#else
+if (pos <= s.size())
+#endif
 {
 S str = s.substr(pos, n);
 LIBCPP_ASSERT(str.__invariants());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(pos <= s.size());
+#endif
 typename S::size_type rlen = std::min(n, s.size() - pos);
 assert(str.size() == rlen);
 assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (std::out_of_range&)
 {
 assert(pos > s.size());
 }
+#endif
 }
 
 int main()
Index: libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
===
--- libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
+++ libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // size_type capacity() const;
@@ -18,21 +17,27 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template 
 void
 test(S s)
 {
 S::allocator_type::throw_after = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 while (s.size() < s.capacity())
 s.push_back(typename S::value_type());
 assert(s.size() == s.capacity());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 S::allocator_type::throw_after = INT_MAX;
 }
 

[libcxx] r287865 - Protect std::string tests under libcpp-no-exceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Nov 24 05:15:09 2016
New Revision: 287865

URL: http://llvm.org/viewvc/llvm-project?rev=287865&view=rev
Log:
Protect std::string tests under libcpp-no-exceptions

Skip tests that expect an exception be thrown and/or disable
unreachable catch handlers.

Differential Revision: https://reviews.llvm.org/D26608


Modified:
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp?rev=287865&r1=287864&r2=287865&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp 
Thu Nov 24 05:15:09 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // size_type capacity() const;
@@ -18,21 +17,27 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template 
 void
 test(S s)
 {
 S::allocator_type::throw_after = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 while (s.size() < s.capacity())
 s.push_back(typename S::value_type());
 assert(s.size() == s.capacity());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 S::allocator_type::throw_after = INT_MAX;
 }
 

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp?rev=287865&r1=287864&r2=287865&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
 Thu Nov 24 05:15:09 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -24,19 +23,27 @@ template 
 void
 test(const S& s, typename S::size_type pos, typename S::size_type n)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#else
+if (pos <= s.size())
+#endif
 {
 S str = s.substr(pos, n);
 LIBCPP_ASSERT(str.__invariants());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(pos <= s.size());
+#endif
 typename S::size_type rlen = std::min(n, s.size() - pos);
 assert(str.size() == rlen);
 assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (std::out_of_range&)
 {
 assert(pos > s.size());
 }
+#endif
 }
 
 int main()


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r287866 - Protect tests for std::uninitialized_{copy, fill} under libcpp-no-exceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Nov 24 05:17:09 2016
New Revision: 287866

URL: http://llvm.org/viewvc/llvm-project?rev=287866&view=rev
Log:
Protect tests for std::uninitialized_{copy,fill} under libcpp-no-exceptions

Skip tests that expect an exception be thrown.

Differential Revision: https://reviews.llvm.org/D26606


Modified:

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp

libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp?rev=287866&r1=287865&r2=287866&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
 Thu Nov 24 05:17:09 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -18,13 +17,21 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count_;
 static int population_;
 int data_;
 explicit B() : data_(1) { ++population_; }
-B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; 
}
+B(const B &b) {
+  ++count_;
+  if (count_ == 3)
+TEST_THROW(1);
+  data_ = b.data_;
+  ++population_;
+}
 ~B() {data_ = 0; --population_; }
 };
 
@@ -49,6 +56,7 @@ int main()
 B* bp = (B*)pool;
 B b[N];
 assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::uninitialized_copy(b, b+N, bp);
@@ -58,6 +66,7 @@ int main()
 {
 assert(B::population_ == N);
 }
+#endif
 B::count_ = 0;
 std::uninitialized_copy(b, b+2, bp);
 for (int i = 0; i < 2; ++i)

Modified: 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp?rev=287866&r1=287865&r2=287866&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
 Thu Nov 24 05:17:09 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -18,13 +17,21 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count_;
 static int population_;
 int data_;
 explicit B() : data_(1) { ++population_; }
-B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; 
}
+B(const B &b) {
+  ++count_;
+  if (count_ == 3)
+TEST_THROW(1);
+  data_ = b.data_;
+  ++population_;
+}
 ~B() {data_ = 0; --population_; }
 };
 
@@ -49,6 +56,7 @@ int main()
 B* bp = (B*)pool;
 B b[N];
 assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::uninitialized_copy_n(b, 5, bp);
@@ -58,6 +66,7 @@ int main()
 {
 assert(B::population_ == N);
 }
+#endif
 B::count_ = 0;
 std::uninitialized_copy_n(b, 2, bp);
 for (int i = 0; i < 2; ++i)

Modified: 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp?rev=287866&r1=287865&r2=287866&view=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
 Thu Nov 24 05:17:09 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -17,13 +16,21 @@
 #include 
 #include 
 
+

[PATCH] D26606: Protect tests for std::uninitialized_{copy, fill} under libcpp-no-exceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL287866: Protect tests for std::uninitialized_{copy,fill} 
under libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26606?vs=77802&id=79207#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26606

Files:
  
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp

Index: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -18,13 +17,21 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count_;
 static int population_;
 int data_;
 explicit B() : data_(1) { ++population_; }
-B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+B(const B &b) {
+  ++count_;
+  if (count_ == 3)
+TEST_THROW(1);
+  data_ = b.data_;
+  ++population_;
+}
 ~B() {data_ = 0; --population_; }
 };
 
@@ -49,6 +56,7 @@
 B* bp = (B*)pool;
 B b[N];
 assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::uninitialized_copy(b, b+N, bp);
@@ -58,6 +66,7 @@
 {
 assert(B::population_ == N);
 }
+#endif
 B::count_ = 0;
 std::uninitialized_copy(b, b+2, bp);
 for (int i = 0; i < 2; ++i)
Index: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -18,13 +17,21 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count_;
 static int population_;
 int data_;
 explicit B() : data_(1) { ++population_; }
-B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+B(const B &b) {
+  ++count_;
+  if (count_ == 3)
+TEST_THROW(1);
+  data_ = b.data_;
+  ++population_;
+}
 ~B() {data_ = 0; --population_; }
 };
 
@@ -49,6 +56,7 @@
 B* bp = (B*)pool;
 B b[N];
 assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::uninitialized_copy_n(b, 5, bp);
@@ -58,6 +66,7 @@
 {
 assert(B::population_ == N);
 }
+#endif
 B::count_ = 0;
 std::uninitialized_copy_n(b, 2, bp);
 for (int i = 0; i < 2; ++i)
Index: libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template 
@@ -18,13 +17,21 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count_;
 static int population_;
 int data_;
 explicit B() : data_(1) { ++population_; }
-B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+B(const B &b) {
+  ++count_;
+  if (count_ == 3)
+TEST_THROW(1);
+  data_ = b.data_;
+  ++population_;
+}
 ~B() {data_ = 0; --population_; }
 };
 
@@ -48,6 +55,7 @@
 char pool[sizeof(B)*N] = {0};
 B* bp = (B*)pool;
 assert(B::population_ == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::uninitialized_fill(bp, bp+N, B());
@@ -57,6 +65,7 @@
 {
 assert(B::population_ == 0);
 }
+#endif
 B::count_ = 0;
 std::uninitialized_fill(bp, bp+2, B());
 for (int i = 0; i < 

[libcxx] r287868 - Reverting wrong diff

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Nov 24 05:28:02 2016
New Revision: 287868

URL: http://llvm.org/viewvc/llvm-project?rev=287868&view=rev
Log:
Reverting wrong diff

I managed to confuse me with two reviews of the same thing and ended commiting 
the wrong one.


Modified:
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp?rev=287868&r1=287867&r2=287868&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp 
Thu Nov 24 05:28:02 2016
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+// XFAIL: libcpp-no-exceptions
 // 
 
 // size_type capacity() const;
@@ -17,27 +18,21 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
-#include "test_macros.h"
-
 template 
 void
 test(S s)
 {
 S::allocator_type::throw_after = 0;
-#ifndef TEST_HAS_NO_EXCEPTIONS
 try
-#endif
 {
 while (s.size() < s.capacity())
 s.push_back(typename S::value_type());
 assert(s.size() == s.capacity());
 }
-#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
-#endif
 S::allocator_type::throw_after = INT_MAX;
 }
 

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp?rev=287868&r1=287867&r2=287868&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
 Thu Nov 24 05:28:02 2016
@@ -7,6 +7,7 @@
 //
 
//===--===//
 
+// XFAIL: libcpp-no-exceptions
 // 
 
 // basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -23,27 +24,19 @@ template 
 void
 test(const S& s, typename S::size_type pos, typename S::size_type n)
 {
-#ifndef TEST_HAS_NO_EXCEPTIONS
 try
-#else
-if (pos <= s.size())
-#endif
 {
 S str = s.substr(pos, n);
 LIBCPP_ASSERT(str.__invariants());
-#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(pos <= s.size());
-#endif
 typename S::size_type rlen = std::min(n, s.size() - pos);
 assert(str.size() == rlen);
 assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
 }
-#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (std::out_of_range&)
 {
 assert(pos > s.size());
 }
-#endif
 }
 
 int main()


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26608: Protect std::string tests under libcpp-no-exceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 reopened this revision.
rogfer01 added a comment.
This revision is now accepted and ready to land.

Somehow I managed to get this wrong. The right review is in 
https://reviews.llvm.org/D26612


Repository:
  rL LLVM

https://reviews.llvm.org/D26608



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27093: Protect std::{, unordered_}map tests under noexceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip tests that use exceptions


https://reviews.llvm.org/D27093

Files:
  test/std/containers/associative/map/map.access/at.pass.cpp
  test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp

Index: test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
===
--- test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
+++ test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template , class Pred = equal_to,
@@ -23,6 +22,7 @@
 
 #include "MoveOnly.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -42,6 +42,7 @@
 assert(c.size() == 4);
 c.at(1) = "ONE";
 assert(c.at(1) == "ONE");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11) = "eleven";
@@ -51,6 +52,7 @@
 {
 }
 assert(c.size() == 4);
+#endif
 }
 {
 typedef std::unordered_map C;
@@ -67,6 +69,7 @@
 const C c(a, a + sizeof(a)/sizeof(a[0]));
 assert(c.size() == 4);
 assert(c.at(1) == "one");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11);
@@ -76,6 +79,7 @@
 {
 }
 assert(c.size() == 4);
+#endif
 }
 #if TEST_STD_VER >= 11
 {
@@ -95,6 +99,7 @@
 assert(c.size() == 4);
 c.at(1) = "ONE";
 assert(c.at(1) == "ONE");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11) = "eleven";
@@ -104,6 +109,7 @@
 {
 }
 assert(c.size() == 4);
+#endif
 }
 {
 typedef std::unordered_map, std::equal_to,
@@ -121,6 +127,7 @@
 const C c(a, a + sizeof(a)/sizeof(a[0]));
 assert(c.size() == 4);
 assert(c.at(1) == "one");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11);
@@ -130,6 +137,7 @@
 {
 }
 assert(c.size() == 4);
+#endif
 }
 #endif
 }
Index: test/std/containers/associative/map/map.access/at.pass.cpp
===
--- test/std/containers/associative/map/map.access/at.pass.cpp
+++ test/std/containers/associative/map/map.access/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class map
@@ -19,6 +18,7 @@
 #include 
 
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -43,14 +43,16 @@
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
 assert(false);
 }
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);
@@ -74,14 +76,16 @@
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
 assert(false);
 }
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);
@@ -108,14 +112,16 @@
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
 assert(false);
 }
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);
@@ -139,14 +145,16 @@
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
 assert(false);
 }
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27095: Protect std::array tests under noexceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect exceptions be thrown.


https://reviews.llvm.org/D27095

Files:
  test/std/containers/sequences/array/at.pass.cpp


Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -40,8 +39,10 @@
 r2 = 7.5;
 assert(c.back() == 7.5);
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try { (void) c.at(3); }
 catch (const std::out_of_range &) {}
+#endif
 }
 {
 typedef double T;
@@ -53,8 +54,10 @@
 C::const_reference r2 = c.at(2);
 assert(r2 == 3.5);
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try { (void) c.at(3); }
 catch (const std::out_of_range &) {}
+#endif
 }
 
 #if TEST_STD_VER > 11


Index: test/std/containers/sequences/array/at.pass.cpp
===
--- test/std/containers/sequences/array/at.pass.cpp
+++ test/std/containers/sequences/array/at.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -40,8 +39,10 @@
 r2 = 7.5;
 assert(c.back() == 7.5);
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try { (void) c.at(3); }
 catch (const std::out_of_range &) {}
+#endif
 }
 {
 typedef double T;
@@ -53,8 +54,10 @@
 C::const_reference r2 = c.at(2);
 assert(r2 == 3.5);
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try { (void) c.at(3); }
 catch (const std::out_of_range &) {}
+#endif
 }
 
 #if TEST_STD_VER > 11
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27096: Protect locale tests under noexceptions

2016-11-24 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect exceptions be thrown.


https://reviews.llvm.org/D27096

Files:
  
test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
  test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
  test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
  test/std/localization/locales/locale/locale.members/combine.pass.cpp

Index: test/std/localization/locales/locale/locale.members/combine.pass.cpp
===
--- test/std/localization/locales/locale/locale.members/combine.pass.cpp
+++ test/std/localization/locales/locale/locale.members/combine.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  locale combine(const locale& other) const;
@@ -18,6 +17,8 @@
 
 #include "count_new.hpp"
 
+#include "test_macros.h"
+
 void check(const std::locale& loc)
 {
 assert(std::has_facet >(loc));
@@ -78,6 +79,7 @@
 }
 assert(globalMemCounter.checkOutstandingNewEq(0));
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 {
 std::locale loc;
@@ -93,4 +95,5 @@
 }
 assert(globalMemCounter.checkOutstandingNewEq(0));
 }
+#endif
 }
Index: test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
===
--- test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
+++ test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
@@ -22,6 +21,8 @@
 #include "count_new.hpp"
 #include "platform_support.h" // locale name macros
 
+#include "test_macros.h"
+
 
 void check(const std::locale& loc)
 {
@@ -70,6 +71,7 @@
 check(loc3);
 assert(!(loc == loc3));
 assert(loc != loc3);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::locale((const char*)0);
@@ -86,6 +88,7 @@
 catch (std::runtime_error&)
 {
 }
+#endif
 std::locale ok("");
 }
 assert(globalMemCounter.checkOutstandingNewEq(0));
Index: test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
===
--- test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
+++ test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
@@ -7,14 +7,15 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  const Facet& use_facet(const locale& loc);
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 int facet_count = 0;
 
 struct my_facet
@@ -32,6 +33,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 const my_facet& f = std::use_facet(std::locale());
@@ -41,6 +43,7 @@
 catch (std::bad_cast&)
 {
 }
+#endif
 const my_facet* fp = 0;
 {
 std::locale loc(std::locale(), new my_facet);
Index: test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
===
--- test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
+++ test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // wstring_convert
@@ -29,6 +28,7 @@
 static_assert(!std::is_convertible::value, "");
 static_assert( std::is_constructible::value, "");
 #endif
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 Myconv myconv;
 try
@@ -48,18 +48,21 @@
 {
 }
 }
+#endif
 {
 Myconv myconv("byte error");
 std::string bs = myconv.to_bytes(L"\xDA83");
 assert(bs == "byte error");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 myconv.from_bytes('\xA5');
 assert(false);
 }
 catch (const std::range_error&)
 {
 }
+#endif
 }
 {
 Myconv myconv("byte error", L"wide error");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288155 - Protect test for dynarray under libcpp-no-exceptions

2016-11-29 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov 29 10:27:45 2016
New Revision: 288155

URL: http://llvm.org/viewvc/llvm-project?rev=288155&view=rev
Log:
Protect test for dynarray under libcpp-no-exceptions

This test expects an exception be thrown.

Differential Revision: https://reviews.llvm.org/D26611


Modified:

libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp?rev=288155&r1=288154&r2=288155&view=diff
==
--- 
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
 Tue Nov 29 10:27:45 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: c++98, c++03, c++11
 
 // dynarray.cons
@@ -29,6 +28,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 
 using std::experimental::dynarray;
 
@@ -61,12 +62,14 @@ void test ( const T &val, bool DefaultVa
 assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ 
return item == val; } ));
 }
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 void test_bad_length () {
 try { dynarray ( std::numeric_limits::max() / sizeof ( int ) 
+ 1 ); }
 catch ( std::bad_array_length & ) { return ; }
 catch (...) { assert(false); }
 assert ( false );
 }
+#endif
 
 
 int main()
@@ -87,5 +90,7 @@ int main()
 assert ( d1.size() == 20 );
 assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return 
item == 3L; } ));
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 test_bad_length ();
+#endif
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288157 - Protect std::{, unordered_}map tests under noexceptions

2016-11-29 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov 29 10:37:48 2016
New Revision: 288157

URL: http://llvm.org/viewvc/llvm-project?rev=288157&view=rev
Log:
Protect std::{,unordered_}map tests under noexceptions

Skip tests that use exceptions

Differential Revision: https://reviews.llvm.org/D27093


Modified:
libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp?rev=288157&r1=288156&r2=288157&view=diff
==
--- libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/associative/map/map.access/at.pass.cpp Tue 
Nov 29 10:37:48 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class map
@@ -19,6 +18,7 @@
 #include 
 
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -43,6 +43,7 @@ int main()
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
@@ -51,6 +52,7 @@ int main()
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);
@@ -74,6 +76,7 @@ int main()
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
@@ -82,6 +85,7 @@ int main()
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);
@@ -108,6 +112,7 @@ int main()
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
@@ -116,6 +121,7 @@ int main()
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);
@@ -139,6 +145,7 @@ int main()
 assert(m.at(3) == 3.5);
 assert(m.at(4) == 4.5);
 assert(m.at(5) == 5.5);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 m.at(6);
@@ -147,6 +154,7 @@ int main()
 catch (std::out_of_range&)
 {
 }
+#endif
 assert(m.at(7) == 7.5);
 assert(m.at(8) == 8.5);
 assert(m.size() == 7);

Modified: 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp?rev=288157&r1=288156&r2=288157&view=diff
==
--- libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp 
Tue Nov 29 10:37:48 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template , class Pred = 
equal_to,
@@ -23,6 +22,7 @@
 
 #include "MoveOnly.h"
 #include "min_allocator.h"
+#include "test_macros.h"
 
 int main()
 {
@@ -42,6 +42,7 @@ int main()
 assert(c.size() == 4);
 c.at(1) = "ONE";
 assert(c.at(1) == "ONE");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11) = "eleven";
@@ -51,6 +52,7 @@ int main()
 {
 }
 assert(c.size() == 4);
+#endif
 }
 {
 typedef std::unordered_map C;
@@ -67,6 +69,7 @@ int main()
 const C c(a, a + sizeof(a)/sizeof(a[0]));
 assert(c.size() == 4);
 assert(c.at(1) == "one");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11);
@@ -76,6 +79,7 @@ int main()
 {
 }
 assert(c.size() == 4);
+#endif
 }
 #if TEST_STD_VER >= 11
 {
@@ -95,6 +99,7 @@ int main()
 assert(c.size() == 4);
 c.at(1) = "ONE";
 assert(c.at(1) == "ONE");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11) = "eleven";
@@ -104,6 +109,7 @@ int main()
 {
 }
 assert(c.size() == 4);
+#endif
 }
 {
 typedef std::unordered_map, 
std::equal_to,
@@ -121,6 +127,7 @@ int main()
 const C c(a, a + sizeof(a)/sizeof(a[0]));
 assert(c.size() == 4);
 assert(c.at(1) == "one");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 c.at(11);
@@ -130,6 +137,7 @@ int main()
 {
  

[libcxx] r288156 - Protect locale tests under noexceptions

2016-11-29 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov 29 10:31:40 2016
New Revision: 288156

URL: http://llvm.org/viewvc/llvm-project?rev=288156&view=rev
Log:
Protect locale tests under noexceptions

Skip tests that expect exceptions be thrown.

Differential Revision: https://reviews.llvm.org/D27096


Modified:

libcxx/trunk/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp

libcxx/trunk/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp

libcxx/trunk/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp

libcxx/trunk/test/std/localization/locales/locale/locale.members/combine.pass.cpp

Modified: 
libcxx/trunk/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp?rev=288156&r1=288155&r2=288156&view=diff
==
--- 
libcxx/trunk/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
 Tue Nov 29 10:31:40 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // wstring_convert
@@ -29,6 +28,7 @@ int main()
 static_assert(!std::is_convertible::value, "");
 static_assert( std::is_constructible::value, "");
 #endif
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 Myconv myconv;
 try
@@ -48,10 +48,12 @@ int main()
 {
 }
 }
+#endif
 {
 Myconv myconv("byte error");
 std::string bs = myconv.to_bytes(L"\xDA83");
 assert(bs == "byte error");
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 myconv.from_bytes('\xA5');
@@ -60,6 +62,7 @@ int main()
 catch (const std::range_error&)
 {
 }
+#endif
 }
 {
 Myconv myconv("byte error", L"wide error");

Modified: 
libcxx/trunk/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp?rev=288156&r1=288155&r2=288156&view=diff
==
--- 
libcxx/trunk/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp
 Tue Nov 29 10:31:40 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  const Facet& use_facet(const locale& loc);
@@ -15,6 +14,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int facet_count = 0;
 
 struct my_facet
@@ -32,6 +33,7 @@ std::locale::id my_facet::id;
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 const my_facet& f = std::use_facet(std::locale());
@@ -41,6 +43,7 @@ int main()
 catch (std::bad_cast&)
 {
 }
+#endif
 const my_facet* fp = 0;
 {
 std::locale loc(std::locale(), new my_facet);

Modified: 
libcxx/trunk/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp?rev=288156&r1=288155&r2=288156&view=diff
==
--- 
libcxx/trunk/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp
 Tue Nov 29 10:31:40 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // REQUIRES: locale.ru_RU.UTF-8
 // REQUIRES: locale.zh_CN.UTF-8
 
@@ -22,6 +21,8 @@
 #include "count_new.hpp"
 #include "platform_support.h" // locale name macros
 
+#include "test_macros.h"
+
 
 void check(const std::locale& loc)
 {
@@ -70,6 +71,7 @@ int main()
 check(loc3);
 assert(!(loc == loc3));
 assert(loc != loc3);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::locale((const char*)0);
@@ -86,6 +88,7 @@ int main()
 catch (std::runtime_error&)
 {
 }
+#endif
 std::locale ok("");
 }
 assert(globalMemCounter.checkOutstandingNewEq(0));

Modified: 
libcxx/trunk/test/std/localization/locales/locale/locale.members/combine.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/localization/locales/locale/locale.members/combine.pass.cpp?rev

[libcxx] r288158 - Protect std::string tests under libcpp-no-exceptions

2016-11-29 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov 29 10:40:19 2016
New Revision: 288158

URL: http://llvm.org/viewvc/llvm-project?rev=288158&view=rev
Log:
Protect std::string tests under libcpp-no-exceptions

Skip tests that expect an exception be thrown and/or disable
unreachable catch handlers.

Differential Revision: https://reviews.llvm.org/D26612


Modified:
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp?rev=288158&r1=288157&r2=288158&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.capacity/capacity.pass.cpp 
Tue Nov 29 10:40:19 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // size_type capacity() const;
@@ -18,21 +17,27 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template 
 void
 test(S s)
 {
 S::allocator_type::throw_after = 0;
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 while (s.size() < s.capacity())
 s.push_back(typename S::value_type());
 assert(s.size() == s.capacity());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 S::allocator_type::throw_after = INT_MAX;
 }
 

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp?rev=288158&r1=288157&r2=288158&view=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp
 Tue Nov 29 10:40:19 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // basic_string substr(size_type pos = 0, size_type n = npos) const;
@@ -24,7 +23,7 @@ template 
 void
 test(const S& s, typename S::size_type pos, typename S::size_type n)
 {
-try
+if (pos <= s.size())
 {
 S str = s.substr(pos, n);
 LIBCPP_ASSERT(str.__invariants());
@@ -33,10 +32,20 @@ test(const S& s, typename S::size_type p
 assert(str.size() == rlen);
 assert(S::traits_type::compare(s.data()+pos, str.data(), rlen) == 0);
 }
-catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos > s.size());
+try
+{
+S str = s.substr(pos, n);
+assert(false);
+}
+catch (std::out_of_range&)
+{
+assert(pos > s.size());
+}
 }
+#endif
 }
 
 int main()


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288165 - Protect std::array tests under noexceptions

2016-11-29 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov 29 11:10:29 2016
New Revision: 288165

URL: http://llvm.org/viewvc/llvm-project?rev=288165&view=rev
Log:
Protect std::array tests under noexceptions

Skip tests that expect exceptions be thrown. Also add missing asserts.

Differential Revision: https://reviews.llvm.org/D27095


Modified:
libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp

Modified: libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp?rev=288165&r1=288164&r2=288165&view=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/sequences/array/at.pass.cpp Tue Nov 29 
11:10:29 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // reference operator[] (size_type)
@@ -40,8 +39,14 @@ int main()
 r2 = 7.5;
 assert(c.back() == 7.5);
 
-try { (void) c.at(3); }
+#ifndef TEST_HAS_NO_EXCEPTIONS
+try
+{
+(void) c.at(3);
+assert(false);
+}
 catch (const std::out_of_range &) {}
+#endif
 }
 {
 typedef double T;
@@ -53,8 +58,14 @@ int main()
 C::const_reference r2 = c.at(2);
 assert(r2 == 3.5);
 
-try { (void) c.at(3); }
+#ifndef TEST_HAS_NO_EXCEPTIONS
+try
+{
+(void) c.at(3);
+assert(false);
+}
 catch (const std::out_of_range &) {}
+#endif
 }
 
 #if TEST_STD_VER > 11


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288378 - Protect std::ostream::sentry test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:31:38 2016
New Revision: 288378

URL: http://llvm.org/viewvc/llvm-project?rev=288378&view=rev
Log:
Protect std::ostream::sentry test under libcpp-no-exceptions

Skip test that throws an exception.

Differential Revision: https://reviews.llvm.org/D27255


Modified:

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp?rev=288378&r1=288377&r2=288378&view=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp
 Thu Dec  1 11:31:38 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  >
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int sync_called = 0;
 
 template 
@@ -58,6 +59,7 @@ int main()
 unitbuf(os);
 }
 assert(sync_called == 1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 testbuf1 sb;
 std::ostream os(&sb);
@@ -73,4 +75,5 @@ int main()
 }
 assert(sync_called == 1);
 }
+#endif
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288379 - Protect optional test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:33:36 2016
New Revision: 288379

URL: http://llvm.org/viewvc/llvm-project?rev=288379&view=rev
Log:
Protect optional test under libcpp-no-exceptions

Replace throw with TEST_THROW and skip tests that throw exceptions

Differential Revision: https://reviews.llvm.org/D27254


Modified:
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp?rev=288379&r1=288378&r2=288379&view=diff
==
--- libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp 
(original)
+++ libcxx/trunk/test/std/experimental/optional/optional.specalg/swap.pass.cpp 
Thu Dec  1 11:33:36 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void swap(optional& x, optional& y)
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -55,10 +56,10 @@ class Z
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == 
y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 int main()
@@ -231,6 +232,7 @@ int main()
 assert(static_cast(opt1) == false);
 assert(static_cast(opt2) == false);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 opt1.emplace(1);
@@ -297,4 +299,5 @@ int main()
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288382 - Protect futures test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:34:57 2016
New Revision: 288382

URL: http://llvm.org/viewvc/llvm-project?rev=288382&view=rev
Log:
Protect futures test under libcpp-no-exceptions

Skip tests that expect an exception be thrown.

Differential Revision: https://reviews.llvm.org/D27253


Modified:
libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp?rev=288382&r1=288381&r2=288382&view=diff
==
--- libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp 
(original)
+++ libcxx/trunk/test/std/thread/futures/futures.promise/move_assign.pass.cpp 
Thu Dec  1 11:34:57 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 // UNSUPPORTED: c++98, c++03
 
@@ -20,6 +19,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 int main()
@@ -34,6 +34,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -43,6 +44,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -55,6 +57,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -64,6 +67,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);
@@ -76,6 +80,7 @@ int main()
 std::future f = p.get_future();
 assert(test_alloc_base::alloc_count == 1);
 assert(f.valid());
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 f = p0.get_future();
@@ -85,6 +90,7 @@ int main()
 {
 assert(e.code() == make_error_code(std::future_errc::no_state));
 }
+#endif
 assert(test_alloc_base::alloc_count == 1);
 }
 assert(test_alloc_base::alloc_count == 0);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288383 - Protect sequences test under libcpp-no-exceptions

2016-12-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Dec  1 11:36:41 2016
New Revision: 288383

URL: http://llvm.org/viewvc/llvm-project?rev=288383&view=rev
Log:
Protect sequences test under libcpp-no-exceptions

Replace throw with TEST_THROW and protect tests that do throw. Also add missing 
assert(false).

Differential Revision: https://reviews.llvm.org/D27252


Modified:

libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp?rev=288383&r1=288382&r2=288383&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
 Thu Dec  1 11:36:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // iterator insert(const_iterator position, size_type n, const value_type& x);
@@ -20,6 +19,7 @@
 
 #include "min_allocator.h"
 #include "count_new.hpp"
+#include "test_macros.h"
 
 template 
 void test() {
@@ -29,6 +29,7 @@ void test() {
 typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
 assert(i == next(l1.begin()));
 assert(l1 == List(a2, a2+8));
+#ifndef TEST_HAS_NO_EXCEPTIONS
 globalMemCounter.throw_after = 4;
 int save_count = globalMemCounter.outstanding_new;
 try
@@ -41,6 +42,7 @@ void test() {
 }
 assert(globalMemCounter.checkOutstandingNewEq(save_count));
 assert(l1 == List(a2, a2+8));
+#endif
 }
 
 int main()

Modified: 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp?rev=288383&r1=288382&r2=288383&view=diff
==
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
 Thu Dec  1 11:36:41 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void push_back(const value_type& x);
@@ -16,10 +15,10 @@
 #include 
 
 #include "asan_testing.h"
+#include "test_macros.h"
 
 // Flag that makes the copy constructor for CMyClass throw an exception
-static bool gCopyConstructorShouldThow = false;
-
+static bool gCopyConstructorShouldThrow = false;
 
 class CMyClass {
 public: CMyClass(int tag);
@@ -52,8 +51,8 @@ CMyClass::CMyClass(const CMyClass& iOthe
 fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
 {
 // If requested, throw an exception _before_ setting fMagicValue to 
kFinishedConstructionMagicValue
-if (gCopyConstructorShouldThow) {
-throw std::exception();
+if (gCopyConstructorShouldThrow) {
+TEST_THROW(std::exception());
 }
 // Signal that the constructor has finished running
 fMagicValue = kFinishedConstructionMagicValue;
@@ -76,12 +75,15 @@ int main()
 assert(is_contiguous_container_asan_correct(vec));
 assert(is_contiguous_container_asan_correct(vec2));
 
-gCopyConstructorShouldThow = true;
+#ifndef TEST_HAS_NO_EXCEPTIONS
+gCopyConstructorShouldThrow = true;
 try {
 vec.push_back(instance);
+assert(false);
 }
 catch (...) {
 assert(vec==vec2);
 assert(is_contiguous_container_asan_correct(vec));
 }
+#endif
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r288660 - Handle tests for noexcept that expect a false value

2016-12-05 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Dec  5 05:05:09 2016
New Revision: 288660

URL: http://llvm.org/viewvc/llvm-project?rev=288660&view=rev
Log:
Handle tests for noexcept that expect a false value

Under libcpp-no-exceptions, noexcept is trivially true. Some tests expect in
the usual setting to return false, so adjust them to expect true under
libcpp-no-exceptions.

Differential Revision: https://reviews.llvm.org/D27310


Modified:
libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp

Modified: libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp?rev=288660&r1=288659&r2=288660&view=diff
==
--- libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/strings/iterators.exceptions.pass.cpp Mon Dec  5 
05:05:09 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // 
 
 // __libcpp_is_trivial_iterator
@@ -26,6 +25,15 @@
 #include "test_macros.h"
 #include "test_iterators.h"
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
+static const bool expected = false;
+#else
+// Under libcpp-no-exceptions all noexcept expressions are trivially true, so
+// any check for a noexcept returning false must actually check for it being
+// true.
+static const bool expected = true;
+#endif
+
 int main()
 {
 //  basic tests
@@ -43,17 +51,17 @@ int main()
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator > > ::value), "");
 
 //  iterators in the libc++ test suite
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, "");
+static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, "");
+static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, "");
+
static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, "");
+
static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, "");
+static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, "");
 
 #if TEST_STD_VER >= 11
 static_assert(( 
std::__libcpp_string_gets_noexcept_iterator 
>::value), "");
 #else
-
static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), "");
+
static_assert(std::__libcpp_string_gets_noexcept_iterator >::value == expected, "");
 #endif
 
 //


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300686 - Avoid assert when a non-static member function is qualified with __unaligned

2017-04-19 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Apr 19 07:23:28 2017
New Revision: 300686

URL: http://llvm.org/viewvc/llvm-project?rev=300686&view=rev
Log:
Avoid assert when a non-static member function is qualified with __unaligned

Under -fms-extensions __unaligned is a type-qualifier that can be applied to a
non-static member function declaration.

This causes an assertion when mangling the name under Itanium, where that
qualifier is not mangled.

This patch justs makes the minimal change to avoid the crash and avoid mangling
__unaligned, as it currently happens with non-member functions.

Differential Revision: https://reviews.llvm.org/D31976


Added:
cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=300686&r1=300685&r2=300686&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Apr 19 07:23:28 2017
@@ -1455,10 +1455,12 @@ void CXXNameMangler::mangleNestedName(co
   Out << 'N';
   if (const CXXMethodDecl *Method = dyn_cast(ND)) {
 Qualifiers MethodQuals =
-Qualifiers::fromCVRMask(Method->getTypeQualifiers());
+Qualifiers::fromCVRUMask(Method->getTypeQualifiers());
 // We do not consider restrict a distinguishing attribute for overloading
 // purposes so we must not mangle it.
 MethodQuals.removeRestrict();
+// __unaligned is not currently mangled in any way, so remove it.
+MethodQuals.removeUnaligned();
 mangleQualifiers(MethodQuals);
 mangleRefQualifier(Method->getRefQualifier());
   }

Added: cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp?rev=300686&view=auto
==
--- cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/unaligned-duplicated-mangle-name.cpp Wed Apr 19 
07:23:28 2017
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fms-extensions -emit-llvm-only 
%s -verify
+
+struct A
+{
+int x;
+void foo() __unaligned;
+void foo();
+};
+
+void A::foo() __unaligned
+{
+this->x++;
+}
+
+void A::foo() // expected-error {{definition with same mangled name as another 
definition}}
+  // expected-note@-6 {{previous definition is here}}
+{
+this->x++;
+}
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-18 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 75007.
rogfer01 added a comment.

Ignore cases where the innermost base expression is too complicated for the 
scope of this patch.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,130 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void g8()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* g9() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
+
+struct S9 {
+  uint32_t x;
+  uint8_t y[2];
+  uint16_t z;
+} __attribute__((__packed__));
+
+typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
+
+void g10() {
+  struct S9 x;
+  struct S9 __attribute__((__aligned__(8))) y;
+  aligned_S9 z;
+
+  uint32_t *p32;
+  p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}}
+  p32 = &y.x; // no-warning
+  p32 = &z.x; // no-warning
+}
+
+typedef struct {
+  uint32_t msgh_bits;
+  uint32_t msgh_size;
+  int32_t msgh_voucher_port;
+  int32_t msgh_id;
+} S10Header;
+
+typedef struct {
+  uint32_t t;
+  uint64_t m;
+  uint32_t p;
+  union {
+struct {
+  uint32_t a;
+  double z;
+} __attribute__((aligned(8), packed)) a;
+struct {
+  uint32_t b;
+  double z;
+  uint32_t a;
+} __attribute__((aligned(8), packed)) b;
+  };

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-21 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 75395.
rogfer01 added a comment.

Mark comment as TODO


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -161,3 +167,130 @@
 {
 return (struct AlignedTo2Bis*)&s->x; // no-warning
 }
+
+struct S6 {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void g8()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* g9() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
+
+struct S9 {
+  uint32_t x;
+  uint8_t y[2];
+  uint16_t z;
+} __attribute__((__packed__));
+
+typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
+
+void g10() {
+  struct S9 x;
+  struct S9 __attribute__((__aligned__(8))) y;
+  aligned_S9 z;
+
+  uint32_t *p32;
+  p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}}
+  p32 = &y.x; // no-warning
+  p32 = &z.x; // no-warning
+}
+
+typedef struct {
+  uint32_t msgh_bits;
+  uint32_t msgh_size;
+  int32_t msgh_voucher_port;
+  int32_t msgh_id;
+} S10Header;
+
+typedef struct {
+  uint32_t t;
+  uint64_t m;
+  uint32_t p;
+  union {
+struct {
+  uint32_t a;
+  double z;
+} __attribute__((aligned(8), packed)) a;
+struct {
+  uint32_t b;
+  double z;
+  uint32_t a;
+} __attribute__((aligned(8), packed)) b;
+  };
+} __attribute__((aligned(8), packed)) S10Data;
+
+typedef struct {
+  S10Hea

[PATCH] D26075: Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: libcpp-no-exceptions" tests that only check exceptions and nothing else

2016-10-28 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: rmaprath, EricWF, mclow.lists.
rogfer01 added a subscriber: cfe-commits.

This is a follow up of https://reviews.llvm.org/D24562.

These tests do not check anything but exceptions, so it makes sense to mark 
them as UNSUPPORTED under a library built without exceptions.


https://reviews.llvm.org/D26075

Files:
  test/libcxx/containers/sequences/vector/asan_throw.pass.cpp
  
test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp
  
test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
  
test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
  
test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
  
test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
  
test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
  
test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
  
test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
  
test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
  
test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
  
test/std/language.support/support.exception/propagation/current_exception.pass.cpp
  
test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
  
test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
  
test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
  
test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
  test/std/strings/basic.string/string.capacity/max_size.pass.cpp
  test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp
  
test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp
  
test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp

Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // 
 
 // template shared_ptr(Y* p, D d, A a);
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullp

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-10-28 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping?


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r285550 - Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: libcpp-no-exceptions" tests that only check exceptions and nothing else

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Oct 31 03:47:53 2016
New Revision: 285550

URL: http://llvm.org/viewvc/llvm-project?rev=285550&view=rev
Log:
Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: 
libcpp-no-exceptions" tests that only check exceptions and nothing else

This is a follow up of D24562.

These tests do not check anything but exceptions, so it makes sense to mark
them as UNSUPPORTED under a library built without exceptions.

Differential Revision: https://reviews.llvm.org/D26075


Modified:
libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp

libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp

libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp

libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp

libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp

libcxx/trunk/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp

libcxx/trunk/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/propagation/current_exception.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp

libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
libcxx/trunk/test/std/strings/basic.string/string.capacity/max_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp

libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp

libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp

libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp?rev=285550&r1=285549&r2=285550&view=diff
==
--- libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp 
Mon Oct 31 03:47:53 2016
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // Test asan vector annotations with a class that throws in a CTOR.
 
 #include 

Modified: 
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp?rev=285550&r1=285549&r2=285550&view=diff
==
--- 
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp
 Mon Oct 31 03:47:53 2016
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // dynarray.cons
 
 // explicit dynarray(size_type c);

Modified: 
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/d

[PATCH] D26075: Change from "XFAIL: libcpp-no-exceptions" to "UNSUPPORTED: libcpp-no-exceptions" tests that only check exceptions and nothing else

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285550: Change from "XFAIL: libcpp-no-exceptions" to 
"UNSUPPORTED: libcpp-no… (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26075?vs=76190&id=76360#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26075

Files:
  libcxx/trunk/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp
  
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp
  
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
  
libcxx/trunk/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/propagation/current_exception.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp
  
libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
  libcxx/trunk/test/std/strings/basic.string/string.capacity/max_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp
  
libcxx/trunk/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp
  
libcxx/trunk/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
  
libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp

Index: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // 
 
 // template shared_ptr(nullptr_t, D d, A a);
Index: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
Index: libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
===
--- libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
+++ libcxx/trunk/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
@@ -7,7 +7,7 @@
 //
 //===--

[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

This is another followup of https://reviews.llvm.org/D24562

These tests are of the form

  try {
 action-that-may-throw
 assert(!exceptional-condition)
 assert(some-other-facts)
   } catch (relevant-exception) {
 assert(exceptional-condition)
   }

Under libcpp-no-exceptions there is still value in verifying
some-other-facts while avoiding the exceptional case. So for these tests
just conditionally check some-other-facts if exceptional-condition is
false.


https://reviews.llvm.org/D26136

Files:
  test/std/strings/basic.string/string.access/at.pass.cpp
  test/std/strings/basic.string/string.capacity/reserve.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
  test/std/strings/basic.string/string.cons/substr.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp

Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // int compare(size_type pos1, size_type n1, const basic_string& str,
@@ -20,6 +19,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
 if (x == 0)
@@ -34,6 +35,7 @@
 test(const S& s,   typename S::size_type pos1, typename S::size_type n1,
  const S& str, typename S::size_type pos2, typename S::size_type n2, int x)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
@@ -44,13 +46,18 @@
 {
 assert(pos1 > s.size() || pos2 > str.size());
 }
+#else
+if (pos1 <= s.size() && pos2 <= str.size())
+assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
+#endif
 }
 
 template 
 void
 test_npos(const S& s,   typename S::size_type pos1, typename S::size_type n1,
   const S& str, typename S::size_type pos2, int x)
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
@@ -61,6 +68,10 @@
 {
 assert(pos1 > s.size() || pos2 > str.size());
 }
+#else
+if (pos1 <= s.size() && pos2 <= str.size())
+assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
+#endif
 }
 
 template 
Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
++

[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added inline comments.



Comment at: test/std/strings/basic.string/string.access/at.pass.cpp:41
+const S& cs = s;
+if (pos < cs.size())
+{

rmaprath wrote:
> For the cases where an exception //should've been// thrown, are we not 
> entering the **undefined** domain at this point?
> 
> What if instead, we define two versions of the `test()` function? one 
> containing the current code as-is, and the other only handles the cases where 
> exceptions are not expected, and we modify the `main()` function below so 
> that the correct `test()` case is invoked depending on the presence  / 
> absence of exceptions? It's a bit more cumbersome than the current setup, but 
> I'm not totally happy about treading into the undefined domain (if my 
> understanding above is correct). 
If I understand this test correctly, it checks for the `at` member function. 
While certainly binding a const reference might throw, here it is bound to a 
lvalue of the same type so no temporary construction should happen.

The original test checks both `s.size()` and `cs.size()`. Given that `size` is 
a const member function it probably does not matter given that `cs` and `s` are 
aliased, but see comment below.



Comment at: test/std/strings/basic.string/string.access/at.pass.cpp:45
+assert(cs.at(pos) == cs[pos]);
+assert(pos < cs.size());
+}

This is redundant, maybe I should change the if condition to be `if (pos < 
s.size())`


https://reviews.llvm.org/D26136



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26139: Tests for strings conversions under libcpp-no-exceptions

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

These files have two styles of tests

  // First style
  try {
action
assert(something-expected);
  } catch ( exception ) {
assert(false);
  }
  
  // Second style
  try {
action
assert(false);
  } catch ( exception ) {
assert(something-expected);
  }

Under libcpp-no-exceptions, we still want to run what is inside the try
block (but not the catch) for first style tests. Second style tests are
skipped as a whole.

Conversions from integers only feature second style tests.

The diff is a bit noisy because it still has to skip `try` keywords
for first style tests. I prefer this to adding a magical TEST_TRY macro
here (catch blocks would look weird and introducing a TEST_CASE macro
does not look appealing to me either)


https://reviews.llvm.org/D26139

Files:
  test/std/strings/string.conversions/stod.pass.cpp
  test/std/strings/string.conversions/stof.pass.cpp
  test/std/strings/string.conversions/stoi.pass.cpp
  test/std/strings/string.conversions/stol.pass.cpp
  test/std/strings/string.conversions/stold.pass.cpp
  test/std/strings/string.conversions/stoll.pass.cpp
  test/std/strings/string.conversions/stoul.pass.cpp
  test/std/strings/string.conversions/stoull.pass.cpp

Index: test/std/strings/string.conversions/stoull.pass.cpp
===
--- test/std/strings/string.conversions/stoull.pass.cpp
+++ test/std/strings/string.conversions/stoull.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
 
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stoull("0") == 0);
@@ -33,6 +34,7 @@
 idx = 0;
 assert(std::stoull(L"10g", &idx, 16) == 16);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 idx = 0;
 try
 {
@@ -108,4 +110,5 @@
 {
 assert(idx == 0);
 }
+#endif
 }
Index: test/std/strings/string.conversions/stoul.pass.cpp
===
--- test/std/strings/string.conversions/stoul.pass.cpp
+++ test/std/strings/string.conversions/stoul.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
 
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stoul("0") == 0);
@@ -33,6 +34,7 @@
 idx = 0;
 assert(std::stoul(L"10g", &idx, 16) == 16);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 idx = 0;
 try
 {
@@ -107,4 +109,5 @@
 {
 assert(idx == 0);
 }
+#endif
 }
Index: test/std/strings/string.conversions/stoll.pass.cpp
===
--- test/std/strings/string.conversions/stoll.pass.cpp
+++ test/std/strings/string.conversions/stoll.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
 
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stoll("0") == 0);
@@ -35,6 +36,7 @@
 idx = 0;
 assert(std::stoll(L"10g", &idx, 16) == 16);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 idx = 0;
 try
 {
@@ -108,4 +110,5 @@
 {
 assert(idx == 0);
 }
+#endif
 }
Index: test/std/strings/string.conversions/stold.pass.cpp
===
--- test/std/strings/string.conversions/stold.pass.cpp
+++ test/std/strings/string.conversions/stold.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // long double stold(const string& str, size_t *idx = 0);
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int main()
 {
 assert(std::stold("0") == 0);
@@ -35,25 +36,32 @@
 idx = 0;
 assert(std::stold(L"10g", &idx) == 10);
 assert(idx == 2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 assert(std::stold("1.e60", &idx) == 1.e60L);
 assert(idx == 5);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
 }
 try
+#endif
 {
 assert(std::stold(L"1.e60", &idx) == 1.e60L);
 assert(idx == 5);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (const std::out_of_range&)
 {
 assert(false);
  

[PATCH] D26141: Protect tests that expect an exception for an unknown std::random_device

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip these tests under libcpp-no-exceptions.


https://reviews.llvm.org/D26141

Files:
  test/std/numerics/rand/rand.device/ctor.pass.cpp
  test/std/numerics/rand/rand.device/eval.pass.cpp


Index: test/std/numerics/rand/rand.device/eval.pass.cpp
===
--- test/std/numerics/rand/rand.device/eval.pass.cpp
+++ test/std/numerics/rand/rand.device/eval.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -26,6 +25,7 @@
 std::random_device::result_type e = r();
 }
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::random_device r("/dev/null");
@@ -35,4 +35,5 @@
 catch (const std::system_error&)
 {
 }
+#endif
 }
Index: test/std/numerics/rand/rand.device/ctor.pass.cpp
===
--- test/std/numerics/rand/rand.device/ctor.pass.cpp
+++ test/std/numerics/rand/rand.device/ctor.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -44,11 +43,13 @@
 }
 
 void check_random_device_invalid(const std::string &token) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
   try {
 std::random_device r(token);
 LIBCPP_ASSERT(false);
   } catch (const std::system_error&) {
   }
+#endif
 }
 
 


Index: test/std/numerics/rand/rand.device/eval.pass.cpp
===
--- test/std/numerics/rand/rand.device/eval.pass.cpp
+++ test/std/numerics/rand/rand.device/eval.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -26,6 +25,7 @@
 std::random_device::result_type e = r();
 }
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::random_device r("/dev/null");
@@ -35,4 +35,5 @@
 catch (const std::system_error&)
 {
 }
+#endif
 }
Index: test/std/numerics/rand/rand.device/ctor.pass.cpp
===
--- test/std/numerics/rand/rand.device/ctor.pass.cpp
+++ test/std/numerics/rand/rand.device/ctor.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -44,11 +43,13 @@
 }
 
 void check_random_device_invalid(const std::string &token) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
   try {
 std::random_device r(token);
 LIBCPP_ASSERT(false);
   } catch (const std::system_error&) {
   }
+#endif
 }
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26142: Protect std::experimental::optional tests under libcpp-no-exceptions

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

In these tests there are some paths that explicitly throw, so use
the TEST_THROW macro that was proposed for this and then skip the tests
that may enter the throwing path.


https://reviews.llvm.org/D26142

Files:
  
test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Index: test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void swap(optional&)
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -56,10 +57,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 struct ConstSwappable {
@@ -231,6 +232,7 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 1);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 optional opt2;
@@ -307,4 +309,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // constexpr const T& optional::value() const;
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 using std::experimental::in_place_t;
 using std::experimental::in_place;
@@ -40,6 +41,7 @@
 const optional opt(in_place);
 assert(opt.value().test() == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 const optional opt;
 try
@@ -51,4 +53,5 @@
 {
 }
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // T& optional::value();
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 using std::experimental::bad_optional_access;
 
@@ -35,6 +36,7 @@
 opt.emplace();
 assert(opt.value().test() == 4);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt;
 try
@@ -46,4 +48,5 @@
 {
 }
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
+++ test/std/experimenta

[PATCH] D26147: Fix archetypes.hpp under libcpp-no-extensions and std level < 14

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Under -fno-exceptions TEST_THROW becomes abort / __builtin_abort which returns 
void. This causes a type mismatch in the conditional operator when testing the 
library in C++98,03,11 modes.

This patch uses a comma operator to workaround this problem.


https://reviews.llvm.org/D26147

Files:
  test/support/archetypes.hpp


Index: test/support/archetypes.hpp
===
--- test/support/archetypes.hpp
+++ test/support/archetypes.hpp
@@ -147,15 +147,15 @@
 protected:
 constexpr static int check_value(int const& val) {
 #if TEST_STD_VER < 14
-  return val == -1 || val == 999 ? TEST_THROW(42) : val;
+  return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
 #else
   assert(val != -1); assert(val != 999);
   return val;
 #endif
 }
 constexpr static int check_value(int& val, int val_cp = 0) {
 #if TEST_STD_VER < 14
-  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? 
TEST_THROW(42) : val_cp);
+  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? 
(TEST_THROW(42), 0) : val_cp);
 #else
   assert(val != -1); assert(val != 999);
   val_cp = val;


Index: test/support/archetypes.hpp
===
--- test/support/archetypes.hpp
+++ test/support/archetypes.hpp
@@ -147,15 +147,15 @@
 protected:
 constexpr static int check_value(int const& val) {
 #if TEST_STD_VER < 14
-  return val == -1 || val == 999 ? TEST_THROW(42) : val;
+  return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
 #else
   assert(val != -1); assert(val != 999);
   return val;
 #endif
 }
 constexpr static int check_value(int& val, int val_cp = 0) {
 #if TEST_STD_VER < 14
-  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? TEST_THROW(42) : val_cp);
+  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? (TEST_THROW(42), 0) : val_cp);
 #else
   assert(val != -1); assert(val != 999);
   val_cp = val;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r285572 - Fix archetypes.hpp under libcpp-no-extensions and std level < 14

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Oct 31 09:14:13 2016
New Revision: 285572

URL: http://llvm.org/viewvc/llvm-project?rev=285572&view=rev
Log:
Fix archetypes.hpp under libcpp-no-extensions and std level < 14

Under -fno-exceptions TEST_THROW becomes abort / __builtin_abort which returns
void. This causes a type mismatch in the conditional operator when testing the
library in C++98,03,11 modes.

Use a comma operator to workaround this problem.

Differential Revision: https://reviews.llvm.org/D26147


Modified:
libcxx/trunk/test/support/archetypes.hpp

Modified: libcxx/trunk/test/support/archetypes.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/archetypes.hpp?rev=285572&r1=285571&r2=285572&view=diff
==
--- libcxx/trunk/test/support/archetypes.hpp (original)
+++ libcxx/trunk/test/support/archetypes.hpp Mon Oct 31 09:14:13 2016
@@ -147,7 +147,7 @@ struct ValueBase {
 protected:
 constexpr static int check_value(int const& val) {
 #if TEST_STD_VER < 14
-  return val == -1 || val == 999 ? TEST_THROW(42) : val;
+  return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
 #else
   assert(val != -1); assert(val != 999);
   return val;
@@ -155,7 +155,7 @@ protected:
 }
 constexpr static int check_value(int& val, int val_cp = 0) {
 #if TEST_STD_VER < 14
-  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? 
TEST_THROW(42) : val_cp);
+  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? 
(TEST_THROW(42), 0) : val_cp);
 #else
   assert(val != -1); assert(val != 999);
   val_cp = val;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26147: Fix archetypes.hpp under libcpp-no-extensions and std level < 14

2016-10-31 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285572: Fix archetypes.hpp under libcpp-no-extensions and 
std level < 14 (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26147?vs=76393&id=76399#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26147

Files:
  libcxx/trunk/test/support/archetypes.hpp


Index: libcxx/trunk/test/support/archetypes.hpp
===
--- libcxx/trunk/test/support/archetypes.hpp
+++ libcxx/trunk/test/support/archetypes.hpp
@@ -147,15 +147,15 @@
 protected:
 constexpr static int check_value(int const& val) {
 #if TEST_STD_VER < 14
-  return val == -1 || val == 999 ? TEST_THROW(42) : val;
+  return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
 #else
   assert(val != -1); assert(val != 999);
   return val;
 #endif
 }
 constexpr static int check_value(int& val, int val_cp = 0) {
 #if TEST_STD_VER < 14
-  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? 
TEST_THROW(42) : val_cp);
+  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? 
(TEST_THROW(42), 0) : val_cp);
 #else
   assert(val != -1); assert(val != 999);
   val_cp = val;


Index: libcxx/trunk/test/support/archetypes.hpp
===
--- libcxx/trunk/test/support/archetypes.hpp
+++ libcxx/trunk/test/support/archetypes.hpp
@@ -147,15 +147,15 @@
 protected:
 constexpr static int check_value(int const& val) {
 #if TEST_STD_VER < 14
-  return val == -1 || val == 999 ? TEST_THROW(42) : val;
+  return val == -1 || val == 999 ? (TEST_THROW(42), 0) : val;
 #else
   assert(val != -1); assert(val != 999);
   return val;
 #endif
 }
 constexpr static int check_value(int& val, int val_cp = 0) {
 #if TEST_STD_VER < 14
-  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? TEST_THROW(42) : val_cp);
+  return val_cp = val, val = -1, (val_cp == -1 || val_cp == 999 ? (TEST_THROW(42), 0) : val_cp);
 #else
   assert(val != -1); assert(val != 999);
   val_cp = val;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26141: Protect tests that expect an exception for an unknown std::random_device

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285677: Protect tests that expect an exception for an 
unknown std::random_device (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26141?vs=76378&id=76527#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26141

Files:
  libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
  libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp


Index: libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
===
--- libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
+++ libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -26,6 +25,7 @@
 std::random_device::result_type e = r();
 }
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::random_device r("/dev/null");
@@ -35,4 +35,5 @@
 catch (const std::system_error&)
 {
 }
+#endif
 }
Index: libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
===
--- libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
+++ libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -44,11 +43,13 @@
 }
 
 void check_random_device_invalid(const std::string &token) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
   try {
 std::random_device r(token);
 LIBCPP_ASSERT(false);
   } catch (const std::system_error&) {
   }
+#endif
 }
 
 


Index: libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
===
--- libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
+++ libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -26,6 +25,7 @@
 std::random_device::result_type e = r();
 }
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::random_device r("/dev/null");
@@ -35,4 +35,5 @@
 catch (const std::system_error&)
 {
 }
+#endif
 }
Index: libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
===
--- libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
+++ libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -44,11 +43,13 @@
 }
 
 void check_random_device_invalid(const std::string &token) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
   try {
 std::random_device r(token);
 LIBCPP_ASSERT(false);
   } catch (const std::system_error&) {
   }
+#endif
 }
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r285677 - Protect tests that expect an exception for an unknown std::random_device

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov  1 03:11:12 2016
New Revision: 285677

URL: http://llvm.org/viewvc/llvm-project?rev=285677&view=rev
Log:
Protect tests that expect an exception for an unknown std::random_device

Skip these tests under libcpp-no-exceptions.

Differential Revision: https://reviews.llvm.org/D26141


Modified:
libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp

Modified: libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp?rev=285677&r1=285676&r2=285677&view=diff
==
--- libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp Tue Nov  1 
03:11:12 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -44,11 +43,13 @@ void check_random_device_valid(const std
 }
 
 void check_random_device_invalid(const std::string &token) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
   try {
 std::random_device r(token);
 LIBCPP_ASSERT(false);
   } catch (const std::system_error&) {
   }
+#endif
 }
 
 

Modified: libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp?rev=285677&r1=285676&r2=285677&view=diff
==
--- libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp Tue Nov  1 
03:11:12 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class random_device;
@@ -26,6 +25,7 @@ int main()
 std::random_device::result_type e = r();
 }
 
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::random_device r("/dev/null");
@@ -35,4 +35,5 @@ int main()
 catch (const std::system_error&)
 {
 }
+#endif
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated the summary for this revision.
rogfer01 updated this revision to Diff 76532.
rogfer01 added a comment.

Update tests following Marshall's suggestion to avoid too much code 
duplication. Also add assert(false) after the throwing action to ensure that 
the expected exception is actually thrown.


https://reviews.llvm.org/D26136

Files:
  test/std/strings/basic.string/string.access/at.pass.cpp
  test/std/strings/basic.string/string.capacity/reserve.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
  test/std/strings/basic.string/string.cons/substr.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp

Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // int compare(size_type pos1, size_type n1, const basic_string& str,
@@ -20,6 +19,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
 if (x == 0)
@@ -34,33 +35,45 @@
 test(const S& s,   typename S::size_type pos1, typename S::size_type n1,
  const S& str, typename S::size_type pos2, typename S::size_type n2, int x)
 {
-try
-{
+if (pos1 <= s.size() && pos2 <= str.size())
 assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
-assert(pos1 <= s.size());
-assert(pos2 <= str.size());
-}
-catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos1 > s.size() || pos2 > str.size());
+try
+{
+s.compare(pos1, n1, str, pos2, n2);
+assert(false);
+}
+catch (const std::out_of_range&)
+{
+assert(pos1 > s.size() || pos2 > str.size());
+}
 }
+#endif
 }
 
 template 
 void
 test_npos(const S& s,   typename S::size_type pos1, typename S::size_type n1,
   const S& str, typename S::size_type pos2, int x)
 {
-try
-{
+if (pos1 <= s.size() && pos2 <= str.size())
 assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
-assert(pos1 <= s.size());
-assert(pos2 <= str.size());
-}
-catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos1 > s.size() || pos2 > str.size());
+try
+{
+s.compare(pos1, n1, str, pos2);
+assert(false);
+}
+catch (const std::out_of_range&)
+{
+assert(pos1 > s.size() || pos2 > str.size());
+}
 }
+#endif
 }
 
 template 
Index: tes

[PATCH] D26184: Protect lock tests under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: rmaprath, mclow.lists, EricWF.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect an exception to be thrown.


https://reviews.llvm.org/D26184

Files:
  test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
  test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
  
test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
  
test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp

Index: test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
===
--- test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
+++ test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -50,19 +49,21 @@
 ++init3_called;
 std::this_thread::sleep_for(ms(250));
 if (init3_called == 1)
-throw 1;
+TEST_THROW(1);
 ++init3_completed;
 }
 
 void f3()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::call_once(flg3, init3);
 }
 catch (...)
 {
 }
+#endif
 }
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -197,6 +198,7 @@
 t1.join();
 assert(init0_called == 1);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 // check basic exception safety
 {
 std::thread t0(f3);
@@ -206,6 +208,7 @@
 assert(init3_called == 2);
 assert(init3_completed == 1);
 }
+#endif
 // check deadlock avoidance
 {
 std::thread t0(f41);
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 bool unlock_called = false;
 
 struct mutex
@@ -35,6 +36,7 @@
 lk.unlock();
 assert(unlock_called == true);
 assert(lk.owns_lock() == false);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 lk.unlock();
@@ -44,7 +46,9 @@
 {
 assert(e.code().value() == EPERM);
 }
+#endif
 lk.release();
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 lk.unlock();
@@ -54,4 +58,5 @@
 {
 assert(e.code().value() == EPERM);
 }
+#endif
 }
Index: test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
===
--- test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
+++ test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -20,6 +19,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 bool try_lock_until_called = false;
 
 struct mutex
@@ -44,6 +45,7 @@
 assert(lk.try_lock_until(Clock::now()) == true);
 assert(try_lock_until_called == true);
 assert(lk.owns_lock() == true);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 lk.try_lock_until(Clock::now());
@@ -53,11 +55,13 @@
 {
 assert(e.code().value() == EDEADLK);
 }
+#endif
 lk.unlock();
 assert(lk.

[PATCH] D26184: Protect lock tests under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285695: Protect lock tests under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26184?vs=76545&id=76559#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26184

Files:
  libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp
  
libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp

Index: libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
===
--- libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -50,19 +49,21 @@
 ++init3_called;
 std::this_thread::sleep_for(ms(250));
 if (init3_called == 1)
-throw 1;
+TEST_THROW(1);
 ++init3_completed;
 }
 
 void f3()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 std::call_once(flg3, init3);
 }
 catch (...)
 {
 }
+#endif
 }
 
 #ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -197,6 +198,7 @@
 t1.join();
 assert(init0_called == 1);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 // check basic exception safety
 {
 std::thread t0(f3);
@@ -206,6 +208,7 @@
 assert(init3_called == 2);
 assert(init3_completed == 1);
 }
+#endif
 // check deadlock avoidance
 {
 std::thread t0(f41);
Index: libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
===
--- libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
+++ libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class L0
 {
 bool locked_;
@@ -63,7 +64,7 @@
 
 bool try_lock()
 {
-throw 1;
+TEST_THROW(1);
 return locked_;
 }
 
@@ -95,6 +96,7 @@
 assert(!l0.locked());
 assert(!l1.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L0 l0;
 L2 l1;
@@ -123,6 +125,7 @@
 assert(!l1.locked());
 }
 }
+#endif
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 {
 L0 l0;
@@ -142,6 +145,7 @@
 assert(!l1.locked());
 assert(!l2.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L2 l0;
 L2 l1;
@@ -167,6 +171,7 @@
 assert(!l1.locked());
 assert(!l2.locked());
 }
+#endif
 {
 L0 l0;
 L0 l1;
@@ -194,6 +199,7 @@
 assert(!l1.locked());
 assert(!l2.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L0 l0;
 L0 l1;
@@ -242,6 +248,7 @@
 assert(!l2.locked());
 }
 }
+#endif
 {
 L1 l0;
 L1 l1;
@@ -269,6 +276,7 @@
 assert(!l1.locked());
 assert(!l2.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L1 l0;
 L1 l1;
@@ -458,6 +466,7 @@
 assert(!l2.locked());
 }
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 {
 L0 l0;
 L0 l

[libcxx] r285695 - Protect lock tests under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov  1 10:00:16 2016
New Revision: 285695

URL: http://llvm.org/viewvc/llvm-project?rev=285695&view=rev
Log:
Protect lock tests under libcpp-no-exceptions

Skip tests that expect an exception to be thrown.

Differential Revision: https://reviews.llvm.org/D26184



Modified:

libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp

libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp

Modified: 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp?rev=285695&r1=285694&r2=285695&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp 
Tue Nov  1 10:00:16 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // This test hangs forever when built against libstdc++. In order to allow
@@ -23,6 +22,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class L0
 {
 bool locked_;
@@ -78,12 +79,12 @@ public:
 
 void lock()
 {
-throw 1;
+TEST_THROW(1);
 }
 
 bool try_lock()
 {
-throw 1;
+TEST_THROW(1);
 return locked_;
 }
 
@@ -115,6 +116,7 @@ int main()
 assert(l0.locked());
 assert(l1.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L0 l0;
 L2 l1;
@@ -185,6 +187,7 @@ int main()
 assert(!l1.locked());
 }
 }
+#endif
 #ifndef _LIBCPP_HAS_NO_VARIADICS
 {
 L0 l0;
@@ -195,6 +198,7 @@ int main()
 assert(l1.locked());
 assert(l2.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L2 l0;
 L2 l1;
@@ -211,6 +215,7 @@ int main()
 assert(!l2.locked());
 }
 }
+#endif
 {
 L0 l0;
 L0 l1;
@@ -238,6 +243,7 @@ int main()
 assert(l1.locked());
 assert(l2.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L0 l0;
 L0 l1;
@@ -382,6 +388,7 @@ int main()
 assert(!l2.locked());
 }
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 {
 L0 l0;
 L0 l1;
@@ -437,6 +444,7 @@ int main()
 assert(l2.locked());
 assert(l3.locked());
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 L0 l0;
 L0 l1;
@@ -509,5 +517,6 @@ int main()
 assert(!l3.locked());
 }
 }
+#endif  // TEST_HAS_NO_EXCEPTIONS
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 }

Modified: 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp?rev=285695&r1=285694&r2=285695&view=diff
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp
 Tue Nov  1 10:00:16 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 //
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: libcpp-has-no-threads
 
 // 
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class L0
 

[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 76566.
rogfer01 added a comment.

Const-ify variables.


https://reviews.llvm.org/D26136

Files:
  test/std/strings/basic.string/string.access/at.pass.cpp
  test/std/strings/basic.string/string.capacity/reserve.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
  test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
  test/std/strings/basic.string/string.cons/substr.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
  test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
  
test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp

Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
+++ test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // int compare(size_type pos1, size_type n1, const basic_string& str,
@@ -20,6 +19,8 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 int sign(int x)
 {
 if (x == 0)
@@ -34,33 +35,45 @@
 test(const S& s,   typename S::size_type pos1, typename S::size_type n1,
  const S& str, typename S::size_type pos2, typename S::size_type n2, int x)
 {
-try
-{
+if (pos1 <= s.size() && pos2 <= str.size())
 assert(sign(s.compare(pos1, n1, str, pos2, n2)) == sign(x));
-assert(pos1 <= s.size());
-assert(pos2 <= str.size());
-}
-catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos1 > s.size() || pos2 > str.size());
+try
+{
+s.compare(pos1, n1, str, pos2, n2);
+assert(false);
+}
+catch (const std::out_of_range&)
+{
+assert(pos1 > s.size() || pos2 > str.size());
+}
 }
+#endif
 }
 
 template 
 void
 test_npos(const S& s,   typename S::size_type pos1, typename S::size_type n1,
   const S& str, typename S::size_type pos2, int x)
 {
-try
-{
+if (pos1 <= s.size() && pos2 <= str.size())
 assert(sign(s.compare(pos1, n1, str, pos2)) == sign(x));
-assert(pos1 <= s.size());
-assert(pos2 <= str.size());
-}
-catch (const std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos1 > s.size() || pos2 > str.size());
+try
+{
+s.compare(pos1, n1, str, pos2);
+assert(false);
+}
+catch (const std::out_of_range&)
+{
+assert(pos1 > s.size() || pos2 > str.size());
+}
 }
+#endif
 }
 
 template 
Index: test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
===
--- test/std/strings/basic.string/string.ops/string_compare/size_size_

[libcxx] r285697 - Protect exceptional paths under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Nov  1 10:46:16 2016
New Revision: 285697

URL: http://llvm.org/viewvc/llvm-project?rev=285697&view=rev
Log:
Protect exceptional paths under libcpp-no-exceptions

These tests are of the form

try {
   action-that-may-throw
   assert(!exceptional-condition)
   assert(some-other-facts)
 } catch (relevant-exception) {
   assert(exceptional-condition)
 }

Under libcpp-no-exceptions there is still value in verifying
some-other-facts while avoiding the exceptional case. So for these tests
just conditionally check some-other-facts if exceptional-condition is
false. When exception are supported make sure that a true
exceptional-condition throws an exception

Differential Revision: https://reviews.llvm.org/D26136


Modified:
libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp
libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp

libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp

Modified: libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp?rev=285697&r1=285696&r2=285697&view=diff
==
--- libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp 
(original)
+++ libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp Tue 
Nov  1 10:46:16 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // const_reference at(size_type pos) const;
@@ -19,21 +18,41 @@
 
 #include "min_allocator.h"
 
+#include "test_macros.h"
+
 template 
 void
 test(S s, typename S::size_type pos)
 {
-try
+const S& cs = s;
+if (pos < s.size())
 {
-const S& cs = s;
 assert(s.at(pos) == s[pos]);
 assert(cs.at(pos) == cs[pos]);
-assert(pos < cs.size());
 }
-catch (std::out_of_range&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(pos >= s.size());
+try
+{
+s.at(pos);
+assert(false);
+}
+catch (std::out_of_range&)
+{
+assert(pos >= s.size());
+}
+try
+{
+cs.at(pos);
+assert(false);
+}
+catch (std::

[PATCH] D26136: Protect exceptional path under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285697: Protect exceptional paths under libcpp-no-exceptions 
(authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26136?vs=76566&id=76567#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26136

Files:
  libcxx/trunk/test/std/strings/basic.string/string.access/at.pass.cpp
  libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp
  libcxx/trunk/test/std/strings/basic.string/string.cons/substr.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/T_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/T_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_T_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_T_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_T_size_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp
  
libcxx/trunk/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp

Index: libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
===
--- libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
+++ libcxx/trunk/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void resize(size_type n);
@@ -23,17 +22,26 @@
 void
 test(S s, typename S::size_type n, S expected)
 {
-try
+if (n <= s.max_size())
 {
 s.resize(n);
 LIBCPP_ASSERT(s.__invariants());
-assert(n <= s.max_size());
 assert(s == expected);
 }
-catch (std::length_error&)
+#ifndef TEST_HAS_NO_EXCEPTIONS
+else
 {
-assert(n > s.max_size());
+try
+{
+s.resize(n);
+assert(false);
+}
+catch (std::length_error&)
+{
+assert(n > s.max_size());
+}
 }
+#endif
 }
 
 int main()
Index: libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
===
--- libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
+++ libcxx/trunk/test/std/strings/basic.string/string.capacity/reserve.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void reserve(size_type res_arg=0);
@@ -38,18 +37,27 @@
 {
 typename S::size_type old_cap = s.capacity();
 S s0 = s;
-try
+if (res_arg <= s.max_size())
 {
 s.reserve(res_arg);
-assert(res_arg <= s.max_size());
 assert(s == s0);
 assert(s.capacity() >= res_arg);
 assert(s.capacity() >= s.size());
 }
-catc

[PATCH] D26197: Protect tests for new/delete under libcpp-no-exceptions

2016-11-01 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip the tests that expect an exception be thrown and protect unreachable catch 
blocks.


https://reviews.llvm.org/D26197

Files:
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
  
test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp

Index: test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new (nothrow)
 
 // asan and msan will not call the new handler.
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@
 int main()
 {
 std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 void* vp = operator new (std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);
 assert(vp == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 A* ap = new(std::nothrow) A;
 assert(ap);
 assert(A_constructed);
Index: test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
@@ -7,8 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
-
 // test operator new
 
 // asan and msan will not call the new handler.
@@ -19,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,6 +37,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 std::set_new_handler(new_handler);
 try
 {
@@ -52,6 +53,7 @@
 {
 assert(false);
 }
+#endif
 A* ap = new A;
 assert(ap);
 assert(A_constructed);
Index: test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new [] (nothrow)
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@
 int main()
 {
 std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif TEST_HAS_NO_EXCEPTIONS
 {
 void*volatile vp = operator new [] (std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);
 assert(vp == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 A* ap = new(std::nothrow) A[3];
 assert(ap);
 assert(A_constructed == 3);
Index: test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
===
--- test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
+++ test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new[]
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -36,6 +37,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 std::set_new_handler(new_handler);
 try
 {
@@ -51,6 +53,7 @@
 {
 assert(false);
 }
+#endif
 A* ap = new A[3];
 assert(ap);
 assert(A_constructed == 3);

[libcxx] r285791 - Protect tests for new/delete under libcpp-no-exceptions

2016-11-02 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Nov  2 03:14:57 2016
New Revision: 285791

URL: http://llvm.org/viewvc/llvm-project?rev=285791&view=rev
Log:
Protect tests for new/delete under libcpp-no-exceptions

Skip the tests that expect an exception be thrown and protect unreachable catch 
blocks.

Differential Revision: https://reviews.llvm.org/D26197


Modified:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp?rev=285791&r1=285790&r2=285791&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
 Wed Nov  2 03:14:57 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new[]
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -36,6 +37,7 @@ struct A
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 std::set_new_handler(new_handler);
 try
 {
@@ -51,6 +53,7 @@ int main()
 {
 assert(false);
 }
+#endif
 A* ap = new A[3];
 assert(ap);
 assert(A_constructed == 3);

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp?rev=285791&r1=285790&r2=285791&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 Wed Nov  2 03:14:57 2016
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new [] (nothrow)
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@ struct A
 int main()
 {
 std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif TEST_HAS_NO_EXCEPTIONS
 {
 void*volatile vp = operator new [] 
(std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);
 assert(vp == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 A* ap = new(std::nothrow) A[3];
 assert(ap);
 assert(A_constructed == 3);

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp?rev=285791&r1=285790&r2=285791&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
 Wed Nov  2 03:14:57 2016
@@ -7,8 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
-
 // test operator new
 
 // asan and msan will not call the new handler.
@@ -19,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,6 +37,7 @@ struct A
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 std::set_new_handler(new_handler);
 try
 {
@@ -52,6 +53,7 @@ int main()
 {
 assert(false);
 }
+#endif
 A* ap = new A;
 assert(ap);
 assert(A_constructed);

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project

[PATCH] D26197: Protect tests for new/delete under libcpp-no-exceptions

2016-11-02 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285791: Protect tests for new/delete under 
libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26197?vs=76575&id=76675#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26197

Files:
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp

Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new (nothrow)
 
 // asan and msan will not call the new handler.
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@
 int main()
 {
 std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif
 {
 void* vp = operator new (std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);
 assert(vp == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 A* ap = new(std::nothrow) A;
 assert(ap);
 assert(A_constructed);
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp
@@ -7,8 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
-
 // test operator new
 
 // asan and msan will not call the new handler.
@@ -19,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,6 +37,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 std::set_new_handler(new_handler);
 try
 {
@@ -52,6 +53,7 @@
 {
 assert(false);
 }
+#endif
 A* ap = new A;
 assert(ap);
 assert(A_constructed);
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new [] (nothrow)
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -37,16 +38,20 @@
 int main()
 {
 std::set_new_handler(new_handler);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
+#endif TEST_HAS_NO_EXCEPTIONS
 {
 void*volatile vp = operator new [] (std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);
 assert(vp == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 catch (...)
 {
 assert(false);
 }
+#endif
 A* ap = new(std::nothrow) A[3];
 assert(ap);
 assert(A_constructed == 3);
Index: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
===
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test operator new[]
 // NOTE: asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 int new_handler_called = 0;
 
 void new_handler()
@@ -36,6 +37,7 @@
 
 int main()

[libcxx] r285792 - Remove spurious token from #endif

2016-11-02 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Wed Nov  2 03:36:43 2016
New Revision: 285792

URL: http://llvm.org/viewvc/llvm-project?rev=285792&view=rev
Log:
Remove spurious token from #endif


Modified:

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp

Modified: 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp?rev=285792&r1=285791&r2=285792&view=diff
==
--- 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp
 Wed Nov  2 03:36:43 2016
@@ -40,7 +40,7 @@ int main()
 std::set_new_handler(new_handler);
 #ifndef TEST_HAS_NO_EXCEPTIONS
 try
-#endif TEST_HAS_NO_EXCEPTIONS
+#endif
 {
 void*volatile vp = operator new [] 
(std::numeric_limits::max(), std::nothrow);
 assert(new_handler_called == 1);


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-11-03 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping? :)


https://reviews.llvm.org/D23657



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26142: Protect std::experimental::optional tests under libcpp-no-exceptions

2016-11-07 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 77018.
rogfer01 added a comment.

Updated with changes suggested by @EricWF


https://reviews.llvm.org/D26142

Files:
  
test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Index: test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void swap(optional&)
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -56,10 +57,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 struct ConstSwappable {
@@ -231,6 +232,7 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 1);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 optional opt2;
@@ -307,4 +309,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // constexpr const T& optional::value() const;
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 using std::experimental::in_place_t;
 using std::experimental::in_place;
@@ -40,6 +41,7 @@
 const optional opt(in_place);
 assert(opt.value().test() == 3);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 const optional opt;
 try
@@ -51,4 +53,5 @@
 {
 }
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // T& optional::value();
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 using std::experimental::bad_optional_access;
 
@@ -35,6 +36,7 @@
 opt.emplace();
 assert(opt.value().test() == 4);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt;
 try
@@ -46,4 +48,5 @@
 {
 }
 }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
===
--- test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 //
 // UNSUPPORTED: c++9

[libcxx] r286099 - Protect std::experimental::optional tests under libcpp-no-exceptions

2016-11-07 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Mon Nov  7 02:23:59 2016
New Revision: 286099

URL: http://llvm.org/viewvc/llvm-project?rev=286099&view=rev
Log:
Protect std::experimental::optional tests under libcpp-no-exceptions

In these tests there are some paths that explicitly throw, so use
the TEST_THROW macro that was proposed for this and then skip the tests
that may enter the throwing path.

Differential Revision: https://reviews.llvm.org/D26142


Modified:

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp?rev=286099&r1=286098&r2=286099&view=diff
==
--- 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
 Mon Nov  7 02:23:59 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // optional& operator=(const optional& rhs);
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 struct AllowConstAssign {
@@ -34,7 +35,7 @@ struct X
 X(const X&)
 {
 if (throw_now)
-throw 6;
+TEST_THROW(6);
 }
 };
 
@@ -79,6 +80,7 @@ int main()
 assert(static_cast(opt) == static_cast(opt2));
 assert(*opt == *opt2);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt;
 optional opt2(X{});
@@ -95,4 +97,5 @@ int main()
 assert(static_cast(opt) == false);
 }
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp?rev=286099&r1=286098&r2=286099&view=diff
==
--- 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
 Mon Nov  7 02:23:59 2016
@@ -8,7 +8,6 @@
 
//===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  void optional::emplace(Args&&... args);
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -48,7 +49,7 @@ class Z
 public:
 static bool dtor_called;
 Z() = default;
-Z(int) {throw 6;}
+Z(int) {TEST_THROW(6);}
 ~Z() {dtor_called = true;}
 };
 
@@ -131,6 +132,7 @@ int main()
 assert(Y::dtor_called == true);
 }
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 Z z;
 optional opt(z);
@@ -147,4 +149,5 @@ int main()
 assert(Z::dtor_called == true);
 }
 }
+#endif
 }

Modified: 
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp?rev=286099&r1=286098&r2=286099&view=diff

[PATCH] D26142: Protect std::experimental::optional tests under libcpp-no-exceptions

2016-11-07 Thread Roger Ferrer Ibanez via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL286099: Protect std::experimental::optional tests under 
libcpp-no-exceptions (authored by rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D26142?vs=77018&id=77019#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26142

Files:
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
  
libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // void swap(optional&)
@@ -19,6 +18,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -56,10 +57,10 @@
 int i_;
 public:
 Z(int i) : i_(i) {}
-Z(Z&&) {throw 7;}
+Z(Z&&) {TEST_THROW(7);}
 
 friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;}
-friend void swap(Z& x, Z& y) {throw 6;}
+friend void swap(Z& x, Z& y) {TEST_THROW(6);}
 };
 
 struct ConstSwappable {
@@ -231,6 +232,7 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 1);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 optional opt1;
 optional opt2;
@@ -307,4 +309,5 @@
 assert(static_cast(opt2) == true);
 assert(*opt2 == 2);
 }
+#endif
 }
Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
@@ -8,7 +8,6 @@
 //===--===//
 //
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 
 // 
 
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 class X
@@ -42,7 +43,7 @@
 {
 public:
 Z(int)  {}
-Z(const Z&) {throw 6;}
+Z(const Z&) {TEST_THROW(6);}
 };
 
 
@@ -97,6 +98,7 @@
 };
 
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 typedef Z T;
 try
@@ -110,4 +112,5 @@
 assert(i == 6);
 }
 }
+#endif
 }
Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -8,15 +8,16 @@
 //===--===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // 
 
 // optional(optional&& rhs) noexcept(is_nothrow_move_constructible::value);
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 template 
@@ -26,16 +27,24 @@
 static_assert(std::is_nothrow_move_constructible>::value ==
   std::is_nothrow_move_constructible::value, "");
 bool rhs_engaged = static_cast(rhs);
+#ifdef TEST_HAS_NO_EXCEPTIONS
+if (is_going_to_throw)
+return;
+#else
 

[PATCH] D26457: Protect smart-pointer tests under no exceptions

2016-11-09 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, rmaprath, mclow.lists.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect an exception be thrown under no-exceptions.


https://reviews.llvm.org/D26457

Files:
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp


Index: 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
===
--- 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // shared_ptr
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count;
@@ -42,6 +43,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::weak_ptr wp;
 try
@@ -54,6 +56,7 @@
 }
 assert(A::count == 0);
 }
+#endif
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -63,6 +66,7 @@
 assert(A::count == 1);
 }
 assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -77,4 +81,5 @@
 }
 }
 assert(A::count == 0);
+#endif
 }
Index: 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===
--- 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ 
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
@@ -63,6 +62,7 @@
 assert(p.get() == raw_ptr);
 assert(ptr.get() == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(A::count == 0);
 {
 std::unique_ptr ptr(new A);
@@ -86,6 +86,7 @@
 #endif
 }
 }
+#endif
 assert(A::count == 0);
 { // LWG 2399
 fn(std::unique_ptr(new int));


Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // shared_ptr
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct B
 {
 static int count;
@@ -42,6 +43,7 @@
 
 int main()
 {
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::weak_ptr wp;
 try
@@ -54,6 +56,7 @@
 }
 assert(A::count == 0);
 }
+#endif
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -63,6 +66,7 @@
 assert(A::count == 1);
 }
 assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 std::shared_ptr sp0(new A);
 std::weak_ptr wp(sp0);
@@ -77,4 +81,5 @@
 }
 }
 assert(A::count == 0);
+#endif
 }
Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // UNSUPPORTED: sanitizer-new-delete
 
 // 
@@ -63,6 +62,7 @@
 assert(p.get() == raw_ptr);
 assert(ptr.get() == 0);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 assert(A::count == 0);
 {
 std::unique_ptr ptr(new A);
@@ -86,6 +86,7 @@
 #endif
 }
 }
+#endif
 assert(A::count == 0);
 { // LWG 2399
 fn(std::unique_ptr(new int));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-09 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect an exception be thrown.


https://reviews.llvm.org/D26458

Files:
  test/std/language.support/support.exception/except.nested/assign.pass.cpp
  test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
  
test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp

Index: test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
===
--- test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
+++ test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -32,6 +33,7 @@
 std::nested_exception e;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -53,4 +55,5 @@
 }
 }
 }
+#endif
 }
Index: test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
===
--- test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
+++ test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -33,6 +34,7 @@
 std::nested_exception e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -55,4 +57,5 @@
 }
 }
 }
+#endif
 }
Index: test/std/language.support/support.exception/except.nested/assign.pass.cpp
===
--- test/std/language.support/support.exception/except.nested/assign.pass.cpp
+++ test/std/language.support/support.exception/except.nested/assign.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // class nested_exception;
@@ -17,6 +16,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 class A
 {
 int data_;
@@ -34,6 +35,7 @@
 e = e0;
 assert(e.nested_ptr() == nullptr);
 }
+#ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try
 {
@@ -57,4 +59,5 @@
 }
 }
 }
+#endif
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 updated this revision to Diff 77498.
rogfer01 added a comment.

- Address comments.
- Rebase test with current trunk
- Make the check resilient under errors

If no comments arise from this change I will be commiting it Monday next week.


https://reviews.llvm.org/D23657

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaChecking.cpp
  test/Sema/address-packed.c

Index: test/Sema/address-packed.c
===
--- test/Sema/address-packed.c
+++ test/Sema/address-packed.c
@@ -26,6 +26,7 @@
 struct Arguable *get_arguable();
 
 void to_void(void *);
+void to_intptr(intptr_t);
 
 void g0(void) {
   {
@@ -41,43 +42,48 @@
 
 f1((int *)(void *)&arguable.x); // no-warning
 to_void(&arguable.x);   // no-warning
-void *p = &arguable.x;  // no-warning;
+void *p = &arguable.x;  // no-warning
 to_void(p);
+to_intptr((intptr_t)p); // no-warning
   }
   {
 union UnionArguable arguable;
 f2(&arguable.c); // no-warning
 f1(&arguable.x); // expected-warning {{packed member 'x' of class or structure 'UnionArguable'}}
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 ArguableT arguable;
 f2(&arguable.c0); // no-warning
 f1(&arguable.x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable.c1); // no-warning
 
-f1((int *)(void *)&arguable.x); // no-warning
-to_void(&arguable.x);   // no-warning
+f1((int *)(void *)&arguable.x);   // no-warning
+to_void(&arguable.x); // no-warning
+to_intptr((intptr_t)&arguable.x); // no-warning
   }
   {
 struct Arguable *arguable = get_arguable();
 f2(&arguable->c0); // no-warning
 f1(&arguable->x);  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&arguable->c1); // no-warning
 
-f1((int *)(void *)&arguable->x); // no-warning
-to_void(&arguable->c1);  // no-warning
+f1((int *)(void *)&arguable->x);// no-warning
+to_void(&arguable->c1); // no-warning
+to_intptr((intptr_t)&arguable->c1); // no-warning
   }
   {
 ArguableT *arguable = get_arguable();
 f2(&(arguable->c0)); // no-warning
 f1(&(arguable->x));  // expected-warning {{packed member 'x' of class or structure 'Arguable'}}
 f2(&(arguable->c1)); // no-warning
 
-f1((int *)(void *)&(arguable->x)); // no-warning
-to_void(&(arguable->c1));  // no-warning
+f1((int *)(void *)&(arguable->x));  // no-warning
+to_void(&(arguable->c1));   // no-warning
+to_intptr((intptr_t)&(arguable->c1));   // no-warning
   }
 }
 
@@ -196,3 +202,130 @@
 int *anonymousInnerUnion(struct S6 *s) {
   return &s->x; // expected-warning {{packed member 'x' of class or structure 'S6::(anonymous)'}}
 }
+
+struct S6a {
+int a;
+int _;
+int c;
+char __;
+int d;
+} __attribute__((packed, aligned(16))) s6;
+
+void g8()
+{ 
+f1(&s6.a); // no-warning
+f1(&s6.c); // no-warning
+f1(&s6.d); // expected-warning {{packed member 'd' of class or structure 'S6a'}}
+}
+
+struct __attribute__((packed, aligned(1))) MisalignedContainee { double d; };
+struct __attribute__((aligned(8))) AlignedContainer { struct MisalignedContainee b; };
+
+struct AlignedContainer *p;
+double* g9() {
+  return &p->b.d; // no-warning
+}
+
+union OneUnion
+{
+uint32_t a;
+uint32_t b:1;
+};
+
+struct __attribute__((packed)) S7 {
+uint8_t length;
+uint8_t stuff;
+uint8_t padding[2];
+union OneUnion one_union;
+};
+
+union AnotherUnion {
+long data;
+struct S7 s;
+} *au;
+
+union OneUnion* get_OneUnion(void)
+{
+return &au->s.one_union; // no-warning
+}
+
+struct __attribute__((packed)) S8 {
+uint8_t data1;
+uint8_t data2;
+	uint16_t wider_data;
+};
+
+#define LE_READ_2(p)	\
+	((uint16_t)	\
+	 const uint8_t *)(p))[0]  ) |		\
+	  (((const uint8_t *)(p))[1] <<  8)))
+
+uint32_t get_wider_data(struct S8 *s)
+{
+return LE_READ_2(&s->wider_data); // no-warning
+}
+
+struct S9 {
+  uint32_t x;
+  uint8_t y[2];
+  uint16_t z;
+} __attribute__((__packed__));
+
+typedef struct S9 __attribute__((__aligned__(16))) aligned_S9;
+
+void g10() {
+  struct S9 x;
+  struct S9 __attribute__((__aligned__(8))) y;
+  aligned_S9 z;
+
+  uint32_t *p32;
+  p32 = &x.x; // expected-warning {{packed member 'x' of class or structure 'S9'}}
+  p32 = &y.x; // no-warning
+  p32 = &z.x; // no-warning
+}
+
+typedef struct {
+  uint32_t msgh_bits;
+  uint32_t msgh_size;
+  int32_t msgh_voucher_port;
+  int32_t msgh_id;
+} S10Header;
+
+typedef struct {
+  uint32_t t;
+  uint64_t m;
+  uint32_t p;
+  union {
+struct {
+  uint32_t a;
+  double z;
+} _

[libcxx] r286474 - Protect bitset tests under libcpp-no-exceptions

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Thu Nov 10 10:54:55 2016
New Revision: 286474

URL: http://llvm.org/viewvc/llvm-project?rev=286474&view=rev
Log:
Protect bitset tests under libcpp-no-exceptions

Bitset tests feature a sequence of tests of increasing bitset sizes,
but these tests rely on exceptions when the bitset size is less than
50 elements.

This change adds a flag to tell whether a test should throw. If it must
throw it will be skipped under no-exceptions.

Differential Revision: https://reviews.llvm.org/D26140


Modified:

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp

libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/test.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff
==
--- 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp
 Thu Nov 10 10:54:55 2016
@@ -7,13 +7,14 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test bitset& flip(size_t pos);
 
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
 std::bitset
 make_bitset()
@@ -25,11 +26,15 @@ make_bitset()
 }
 
 template 
-void test_flip_one()
+void test_flip_one(bool test_throws)
 {
 std::bitset v = make_bitset();
+#ifdef TEST_HAS_NO_EXCEPTIONS
+if (test_throws) return;
+#else
 try
 {
+#endif
 v.flip(50);
 bool b = v[50];
 if (50 >= v.size())
@@ -39,21 +44,25 @@ void test_flip_one()
 assert(v[50] != b);
 v.flip(50);
 assert(v[50] == b);
+assert(!test_throws);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 }
 catch (std::out_of_range&)
 {
+assert(test_throws);
 }
+#endif
 }
 
 int main()
 {
-test_flip_one<0>();
-test_flip_one<1>();
-test_flip_one<31>();
-test_flip_one<32>();
-test_flip_one<33>();
-test_flip_one<63>();
-test_flip_one<64>();
-test_flip_one<65>();
-test_flip_one<1000>();
+test_flip_one<0>(true);
+test_flip_one<1>(true);
+test_flip_one<31>(true);
+test_flip_one<32>(true);
+test_flip_one<33>(true);
+test_flip_one<63>(false);
+test_flip_one<64>(false);
+test_flip_one<65>(false);
+test_flip_one<1000>(false);
 }

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff
==
--- 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp
 Thu Nov 10 10:54:55 2016
@@ -7,18 +7,23 @@
 //
 
//===--===//
 
-// XFAIL: libcpp-no-exceptions
 // test bitset& reset(size_t pos);
 
 #include 
 #include 
 
+#include "test_macros.h"
+
 template 
-void test_reset_one()
+void test_reset_one(bool test_throws)
 {
 std::bitset v;
+#ifdef TEST_HAS_NO_EXCEPTIONS
+if (test_throws) return;
+#else
 try
 {
+#endif
 v.set();
 v.reset(50);
 if (50 >= v.size())
@@ -28,21 +33,25 @@ void test_reset_one()
 assert(!v[i]);
 else
 assert(v[i]);
+assert(!test_throws);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 }
 catch (std::out_of_range&)
 {
+assert(test_throws);
 }
+#endif
 }
 
 int main()
 {
-test_reset_one<0>();
-test_reset_one<1>();
-test_reset_one<31>();
-test_reset_one<32>();
-test_reset_one<33>();
-test_reset_one<63>();
-test_reset_one<64>();
-test_reset_one<65>();
-test_reset_one<1000>();
+test_reset_one<0>(true);
+test_reset_one<1>(true);
+test_reset_one<31>(true);
+test_reset_one<32>(true);
+test_reset_one<33>(true);
+test_reset_one<63>(false);
+test_reset_one<64>(false);
+test_reset_one<65>(false);
+test_reset_one<1000>(false);
 }

Modified: 
libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp?rev=286474&r1=286473&r2=286474&view=diff
===

[PATCH] D26458: Protect nested-exceptions tests under no-exceptions

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

@rmaprath well each case is testing a different special member: the assignment 
operator, the copy constructor and the default constructor. My feeling is that 
at least the non-throwing part must be tested under no-exceptions. But I 
understand, that this class is probably useless in the context of no-exceptions.


https://reviews.llvm.org/D26458



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26512: Protect std::ios tests under libcpp-no-exceptions

2016-11-10 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: EricWF, mclow.lists, rmaprath.
rogfer01 added a subscriber: cfe-commits.

Skip tests that expect an exception be thrown.


https://reviews.llvm.org/D26512

Files:
  test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
  test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
  
test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
  test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp

Index: test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,14 +17,17 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
 {
 {
 std::ios ios(0);
 ios.setstate(std::ios::goodbit);
 assert(ios.rdstate() == std::ios::badbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
@@ -51,6 +53,7 @@
 {
 assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
 }
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
@@ -27,6 +28,7 @@
 assert(ios.exceptions() == std::ios::goodbit);
 ios.exceptions(std::ios::eofbit);
 assert(ios.exceptions() == std::ios::eofbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
@@ -36,6 +38,7 @@
 {
 }
 assert(ios.exceptions() == std::ios::badbit);
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
+++ test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,14 +17,17 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf : public std::streambuf {};
 
 int main()
 {
 {
 std::ios ios(0);
 ios.clear();
 assert(ios.rdstate() == std::ios::badbit);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.exceptions(std::ios::badbit);
@@ -51,6 +53,7 @@
 {
 assert(ios.rdstate() == (std::ios::eofbit | std::ios::badbit));
 }
+#endif
 }
 {
 testbuf sb;
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
+++ test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-// XFAIL: libcpp-no-exceptions
 // 
 
 // template  class basic_ios
@@ -18,6 +17,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 struct testbuf
 : public std::streambuf
 {
@@ -35,24 +36,28 @@
 testbuf sb1;
 testbuf sb2;
 testios ios(&sb1);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.setstate(std::ios::badbit);
 ios.exceptions(std::ios::badbit);
 }
 catch (...)
 {
 }
+#endif
 ios.set_rdbuf(&sb2);
 assert(ios.rdbuf() == &sb2);
+#ifndef TEST_HAS_NO_EXCEPTIONS
 try
 {
 ios.setstate(std::ios::badbit);
 ios.exceptions(std::ios::badbit);
 }
 catch (...)
 {
 }
+#endif
 ios.set_rdbuf(0);
 assert(ios.rdbuf() == 0);
 }
Index: test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp
===
--- test/std/input.output/iostreams.base/ios/basic.ios.member

  1   2   >