r349755 - [Sema][NFC] Add test for static_assert diagnistics with constexpr template functions.

Clement Courbet via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 20 05:30:40 PST 2018


Author: courbet
Date: Thu Dec 20 05:30:40 2018
New Revision: 349755

URL: http://llvm.org/viewvc/llvm-project?rev=349755&view=rev
Log:
[Sema][NFC] Add test for static_assert diagnistics with constexpr template functions.

Modified:
    cfe/trunk/test/SemaCXX/static-assert-cxx17.cpp

Modified: cfe/trunk/test/SemaCXX/static-assert-cxx17.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/static-assert-cxx17.cpp?rev=349755&r1=349754&r2=349755&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/static-assert-cxx17.cpp (original)
+++ cfe/trunk/test/SemaCXX/static-assert-cxx17.cpp Thu Dec 20 05:30:40 2018
@@ -15,6 +15,11 @@ struct S2 {
 };
 
 template <typename U, typename V>
+inline constexpr bool constexpr_return_false() {
+  return false;
+}
+
+template <typename U, typename V>
 void foo() {
   static_assert(S1<U, V>::value);
   // expected-error at -1{{static_assert failed due to requirement 'S1<int, float>::value'}}
@@ -92,6 +97,8 @@ void foo6() {
   // expected-error at -1{{static_assert failed due to requirement '(X<int> const[0]){} == nullptr'}}
   static_assert(sizeof(X<decltype(X<typename T::T>().X<typename T::T>::~X())>) == 0);
   // expected-error at -1{{static_assert failed due to requirement 'sizeof(X<void>) == 0'}}
+  static_assert(constexpr_return_false<typename T::T, typename T::U>());
+  // expected-error at -1{{static_assert failed due to requirement 'constexpr_return_false<int, float>()'}}
 }
 template void foo6<ExampleTypes>();
 // expected-note at -1{{in instantiation of function template specialization 'foo6<ExampleTypes>' requested here}}




More information about the cfe-commits mailing list