forked from OSchip/llvm-project
Revert "Rewording the "static_assert" to static assertion"
Looks like we again are going to have problems with libcxx tests that
are overly specific in their dependency on clang's diagnostics.
This reverts commit 6542cb55a3
.
This commit is contained in:
parent
888d0a5ef2
commit
1da3119025
|
@ -282,7 +282,7 @@ def err_inline_nested_namespace_definition : Error<
|
|||
def err_expected_semi_after_attribute_list : Error<
|
||||
"expected ';' after attribute list">;
|
||||
def err_expected_semi_after_static_assert : Error<
|
||||
"expected ';' after '%0'">;
|
||||
"expected ';' after static_assert">;
|
||||
def err_expected_semi_for : Error<"expected ';' in 'for' statement specifier">;
|
||||
def err_single_decl_assign_in_for_range : Error<
|
||||
"range-based 'for' statement uses ':', not '='">;
|
||||
|
@ -425,7 +425,7 @@ def err_unexpected_token_in_nested_name_spec : Error<
|
|||
def err_bool_redeclaration : Error<
|
||||
"redeclaration of C++ built-in type 'bool'">;
|
||||
def warn_cxx98_compat_static_assert : Warning<
|
||||
"'static_assert' declarations are incompatible with C++98">,
|
||||
"static_assert declarations are incompatible with C++98">,
|
||||
InGroup<CXX98Compat>, DefaultIgnore;
|
||||
def ext_ms_static_assert : ExtWarn<
|
||||
"use of 'static_assert' without inclusion of <assert.h> is a Microsoft "
|
||||
|
|
|
@ -1526,12 +1526,12 @@ def err_messaging_class_with_direct_method : Error<
|
|||
|
||||
// C++ declarations
|
||||
def err_static_assert_expression_is_not_constant : Error<
|
||||
"static assertion expression is not an integral constant expression">;
|
||||
"static_assert expression is not an integral constant expression">;
|
||||
def err_constexpr_if_condition_expression_is_not_constant : Error<
|
||||
"constexpr if condition is not a constant expression">;
|
||||
def err_static_assert_failed : Error<"static assertion failed%select{: %1|}0">;
|
||||
def err_static_assert_failed : Error<"static_assert failed%select{: %1|}0">;
|
||||
def err_static_assert_requirement_failed : Error<
|
||||
"static assertion failed due to requirement '%0'%select{: %2|}1">;
|
||||
"static_assert failed due to requirement '%0'%select{: %2|}1">;
|
||||
|
||||
def warn_consteval_if_always_true : Warning<
|
||||
"consteval if is always true in an %select{unevaluated|immediate}0 context">,
|
||||
|
|
|
@ -1043,7 +1043,7 @@ private:
|
|||
/// If the next token is not a semicolon, this emits the specified diagnostic,
|
||||
/// or, if there's just some closing-delimiter noise (e.g., ')' or ']') prior
|
||||
/// to the semicolon, consumes that extra token.
|
||||
bool ExpectAndConsumeSemi(unsigned DiagID , StringRef TokenUsed = "");
|
||||
bool ExpectAndConsumeSemi(unsigned DiagID);
|
||||
|
||||
/// The kind of extra semi diagnostic to emit.
|
||||
enum ExtraSemiKind {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -153,7 +153,7 @@ bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID,
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed) {
|
||||
bool Parser::ExpectAndConsumeSemi(unsigned DiagID) {
|
||||
if (TryConsumeToken(tok::semi))
|
||||
return false;
|
||||
|
||||
|
@ -172,7 +172,7 @@ bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed) {
|
|||
return false;
|
||||
}
|
||||
|
||||
return ExpectAndConsume(tok::semi, DiagID , TokenUsed);
|
||||
return ExpectAndConsume(tok::semi, DiagID);
|
||||
}
|
||||
|
||||
void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST TST) {
|
||||
|
|
|
@ -203,7 +203,7 @@ _Static_assert(THIS$AND$THAT(1, 1) == 2, "fail"); /* expected-warning 2 {{'$' in
|
|||
* Note: the rule changed in C99 to be different than the resolution to DR029,
|
||||
* so it's not clear there's value in implementing this DR.
|
||||
*/
|
||||
_Static_assert(__builtin_types_compatible_p(struct S { int a; }, union U { int a; }), "fail"); /* expected-error {{static assertion failed due to requirement '__builtin_types_compatible_p(struct S, union U)': fail}} */
|
||||
_Static_assert(__builtin_types_compatible_p(struct S { int a; }, union U { int a; }), "fail"); /* expected-error {{static_assert failed due to requirement '__builtin_types_compatible_p(struct S, union U)': fail}} */
|
||||
|
||||
/* WG14 DR031: yes
|
||||
* Can constant expressions overflow?
|
||||
|
|
|
@ -18,4 +18,4 @@ static_assert(S(false), "not so fast"); // expected-error {{not so fast}}
|
|||
static_assert(T(), "");
|
||||
static_assert(U(), ""); // expected-error {{ambiguous}}
|
||||
|
||||
static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static assertion failed: L"\024hi!\""}}
|
||||
static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static_assert failed: L"\024hi!\""}}
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace dr1940 { // dr1940: yes
|
|||
#if __cplusplus >= 201103L
|
||||
static union {
|
||||
static_assert(true, ""); // ok
|
||||
static_assert(false, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(false, ""); // expected-error {{static_assert failed}}
|
||||
int not_empty;
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -161,10 +161,10 @@ concept Large = sizeof(T) > 100;
|
|||
|
||||
struct small { };
|
||||
static_assert(Large<small>);
|
||||
// expected-error@-1 {{static assertion failed}}
|
||||
// expected-error@-1 {{static_assert failed}}
|
||||
// expected-note@-2 {{because 'small' does not satisfy 'Large'}}
|
||||
static_assert(Large<small>, "small isn't large");
|
||||
// expected-error@-1 {{static assertion failed: small isn't large}}
|
||||
// expected-error@-1 {{static_assert failed: small isn't large}}
|
||||
// expected-note@-2 {{because 'small' does not satisfy 'Large'}}
|
||||
|
||||
// Make sure access-checking can fail a concept specialization
|
||||
|
@ -173,7 +173,7 @@ class T4 { static constexpr bool f = true; };
|
|||
template<typename T> concept AccessPrivate = T{}.f;
|
||||
// expected-note@-1{{because substituted constraint expression is ill-formed: 'f' is a private member of 'T4'}}
|
||||
static_assert(AccessPrivate<T4>);
|
||||
// expected-error@-1{{static assertion failed}}
|
||||
// expected-error@-1{{static_assert failed}}
|
||||
// expected-note@-2{{because 'T4' does not satisfy 'AccessPrivate'}}
|
||||
|
||||
template<typename T, typename U>
|
||||
|
|
|
@ -43,5 +43,5 @@ namespace std_example {
|
|||
requires sizeof(a) == 4; // OK
|
||||
requires a == 0; // expected-note{{because 'a == 0' would be invalid: constraint variable 'a' cannot be used in an evaluated context}}
|
||||
};
|
||||
static_assert(C2<int>); // expected-note{{because 'int' does not satisfy 'C2'}} expected-error{{static assertion failed}}
|
||||
}
|
||||
static_assert(C2<int>); // expected-note{{because 'int' does not satisfy 'C2'}} expected-error{{static_assert failed}}
|
||||
}
|
|
@ -79,6 +79,6 @@ namespace variable_templates
|
|||
// expected-note@-1{{while checking constraint satisfaction for variable template partial specialization 'v1<int>' required here}}
|
||||
// expected-note@-2{{during template argument deduction for variable template partial specialization 'v1<T *>' [with T = int *]}}
|
||||
// expected-note@-3{{during template argument deduction for variable template partial specialization 'v1<T **>' [with T = int]}}
|
||||
// expected-error@-4{{static assertion failed due to requirement 'v1<int **>'}}
|
||||
// expected-error@-4{{static_assert failed due to requirement 'v1<int **>'}}
|
||||
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ template<int N> struct T {
|
|||
|
||||
#else
|
||||
|
||||
// expected-error@15 {{static assertion failed due to requirement '1 == 2': N is not 2!}}
|
||||
// expected-error@15 {{static_assert failed due to requirement '1 == 2': N is not 2!}}
|
||||
T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
|
||||
T<2> t2;
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ namespace DependentMemberExpr {
|
|||
// This used to mark 'f' invalid without producing any diagnostic. That's a
|
||||
// little hard to detect, but we can make sure that constexpr evaluation
|
||||
// fails when it should.
|
||||
static_assert(A<int>().f() == 1); // expected-error {{static assertion failed}}
|
||||
static_assert(A<int>().f() == 1); // expected-error {{static_assert failed}}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
@interface A {
|
||||
int a;
|
||||
_Static_assert(1, "");
|
||||
_Static_assert(0, ""); // expected-error {{static assertion failed}}
|
||||
_Static_assert(0, ""); // expected-error {{static_assert failed}}
|
||||
|
||||
_Static_assert(a, ""); // expected-error {{use of undeclared identifier 'a'}}
|
||||
_Static_assert(sizeof(a), ""); // expected-error {{use of undeclared identifier 'a'}}
|
||||
|
@ -44,7 +44,7 @@ struct S {
|
|||
@interface A {
|
||||
int a;
|
||||
_Static_assert(1, "");
|
||||
_Static_assert(0, ""); // expected-error {{static assertion failed}}
|
||||
_Static_assert(0, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
_Static_assert(1, "");
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
static_assert(1, "");
|
||||
_Static_assert(1, "");
|
||||
|
||||
static_assert(0, ""); // expected-error {{static assertion failed}}
|
||||
_Static_assert(0, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(0, ""); // expected-error {{static_assert failed}}
|
||||
_Static_assert(0, ""); // expected-error {{static_assert failed}}
|
||||
|
||||
static_assert(a, ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(a, ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(sizeof(a) == 4, "");
|
||||
static_assert(sizeof(a) == 3, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(sizeof(a) == 3, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
static_assert(1, "");
|
||||
|
@ -40,7 +40,7 @@ _Static_assert(1, "");
|
|||
static_assert(1, "");
|
||||
_Static_assert(1, "");
|
||||
static_assert(sizeof(b) == 4, "");
|
||||
static_assert(sizeof(b) == 3, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(sizeof(b) == 3, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
static_assert(1, "");
|
||||
|
@ -56,7 +56,7 @@ static_assert(1, "");
|
|||
@interface B () {
|
||||
int b;
|
||||
static_assert(sizeof(b) == 4, "");
|
||||
static_assert(sizeof(b) == 3, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(sizeof(b) == 3, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -71,7 +71,7 @@ static_assert(1, "");
|
|||
int a;
|
||||
static_assert(1, ""); // expected-error {{type name requires a specifier or qualifier}} expected-error{{expected parameter declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
_Static_assert(1, "");
|
||||
_Static_assert(0, ""); // expected-error {{static assertion failed}}
|
||||
_Static_assert(0, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
|
|
@ -113,8 +113,8 @@ void constant_expression(int x) {
|
|||
_Static_assert(__builtin_align_down(33, 32) == 32, "");
|
||||
|
||||
// But not if one of the arguments isn't constant:
|
||||
_Static_assert(ALIGN_BUILTIN(33, x) != 100, ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
_Static_assert(ALIGN_BUILTIN(x, 4) != 100, ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
_Static_assert(ALIGN_BUILTIN(33, x) != 100, ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
_Static_assert(ALIGN_BUILTIN(x, 4) != 100, ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
}
|
||||
|
||||
// Check that it is a constant expression that can be assigned to globals:
|
||||
|
|
|
@ -69,7 +69,7 @@ void func(int sel) {
|
|||
// Using pointers to sizeless data isn't wrong here, but because the
|
||||
// type is incomplete, it doesn't provide any alignment guarantees.
|
||||
_Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
|
||||
_Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
_Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
_Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), "");
|
||||
|
||||
local_int8; // expected-warning {{expression result unused}}
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
|
||||
_Static_assert("foo", "string is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
#ifndef __cplusplus
|
||||
// expected-error@-2 {{static assertion expression is not an integral constant expression}}
|
||||
// expected-error@-2 {{static_assert expression is not an integral constant expression}}
|
||||
#endif
|
||||
|
||||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static assertion failed: 0 is nonzero}} \
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed: 0 is nonzero}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
|
||||
#ifdef MS
|
||||
|
@ -18,7 +18,7 @@ static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without
|
|||
|
||||
void foo(void) {
|
||||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static assertion failed: 0 is nonzero}} \
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed: 0 is nonzero}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
#ifdef MS
|
||||
static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without}}
|
||||
|
@ -31,7 +31,7 @@ _Static_assert(1, invalid); // expected-error {{expected string literal for diag
|
|||
struct A {
|
||||
int a;
|
||||
_Static_assert(1, "1 is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static assertion failed: 0 is nonzero}} \
|
||||
_Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed: 0 is nonzero}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
#ifdef MS
|
||||
static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without}}
|
||||
|
@ -54,7 +54,7 @@ struct A {
|
|||
|
||||
typedef UNION(unsigned, struct A) U1; // ext-warning 3 {{'_Static_assert' is a C11 extension}}
|
||||
UNION(char[2], short) u2 = { .one = { 'a', 'b' } }; // ext-warning 3 {{'_Static_assert' is a C11 extension}} cxx-warning {{designated initializers are a C++20 extension}}
|
||||
typedef UNION(char, short) U3; // expected-error {{static assertion failed due to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
|
||||
typedef UNION(char, short) U3; // expected-error {{static_assert failed due to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \
|
||||
// ext-warning 3 {{'_Static_assert' is a C11 extension}}
|
||||
typedef UNION(float, 0.5f) U4; // expected-error {{expected a type}} \
|
||||
// ext-warning 3 {{'_Static_assert' is a C11 extension}}
|
||||
|
@ -70,6 +70,3 @@ static_assert(1, "1 is nonzero"); // ok
|
|||
#undef static_assert
|
||||
static_assert(1, "1 is nonzero"); // ms-warning {{use of 'static_assert' without}}
|
||||
#endif
|
||||
|
||||
_Static_assert(1 , "") // expected-error {{expected ';' after '_Static_assert'}} \
|
||||
// ext-warning {{'_Static_assert' is a C11 extension}}
|
||||
|
|
|
@ -109,7 +109,7 @@ class b {
|
|||
|
||||
template <int>
|
||||
struct Impossible {
|
||||
static_assert(false, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(false, ""); // expected-error {{static_assert failed}}
|
||||
};
|
||||
|
||||
// verify "no member named 'value'" bogus diagnostic is not emitted.
|
||||
|
|
|
@ -174,7 +174,7 @@ struct S {
|
|||
using T = X[J];
|
||||
using U = T<I>;
|
||||
};
|
||||
static_assert(__is_same(S<3>::U, X[2]), ""); // expected-error {{static assertion failed}}
|
||||
static_assert(__is_same(S<3>::U, X[2]), ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
namespace PR39623 {
|
||||
|
|
|
@ -26,7 +26,7 @@ static_assert(cn == 11);
|
|||
constexpr int bn = __builtin_is_constant_evaluated() ? dummy : 42; // expected-note {{non-const variable 'dummy' is not allowed}}
|
||||
|
||||
const int n2 = __builtin_is_constant_evaluated() ? dummy : 42; // expected-note {{declared here}}
|
||||
static_assert(n2 == 42); // expected-error {{static assertion expression is not an integral constant}}
|
||||
static_assert(n2 == 42); // expected-error {{static_assert expression is not an integral constant}}
|
||||
// expected-note@-1 {{initializer of 'n2' is not a constant expression}}
|
||||
|
||||
template <bool V, bool Default = std::is_constant_evaluated()>
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace std {
|
|||
return static_cast<T&&>(x);
|
||||
}
|
||||
template<typename T> CONSTEXPR T &&forward(typename remove_reference<T>::type &&x) {
|
||||
static_assert(!is_lvalue_reference<T>::value, "should not forward rval as lval"); // expected-error {{static assertion failed}}
|
||||
static_assert(!is_lvalue_reference<T>::value, "should not forward rval as lval"); // expected-error {{static_assert failed}}
|
||||
return static_cast<T&&>(x);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace function_start {
|
|||
void a(void) {}
|
||||
int n;
|
||||
void *p = __builtin_function_start(n); // expected-error {{argument must be a function}}
|
||||
static_assert(__builtin_function_start(a) == a, ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(__builtin_function_start(a) == a, ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
} // namespace function_start
|
||||
|
||||
void no_ms_builtins() {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// Test the constant folding of builtin complex numbers.
|
||||
|
||||
static_assert((0.0 + 0.0j) == (0.0 + 0.0j));
|
||||
static_assert((0.0 + 0.0j) != (0.0 + 0.0j)); // expected-error {{static assertion}}
|
||||
static_assert((0.0 + 0.0j) != (0.0 + 0.0j)); // expected-error {{static_assert}}
|
||||
|
||||
static_assert((0.0 + 0.0j) == 0.0);
|
||||
static_assert(0.0 == (0.0 + 0.0j));
|
||||
|
@ -14,21 +14,21 @@ static_assert(0.0 != 1.0j);
|
|||
|
||||
// Walk around the complex plane stepping between angular differences and
|
||||
// equality.
|
||||
static_assert((1.0 + 0.0j) == (0.0 + 0.0j)); // expected-error {{static assertion}}
|
||||
static_assert((1.0 + 0.0j) == (0.0 + 0.0j)); // expected-error {{static_assert}}
|
||||
static_assert((1.0 + 0.0j) == (1.0 + 0.0j));
|
||||
static_assert((1.0 + 1.0j) == (1.0 + 0.0j)); // expected-error {{static assertion}}
|
||||
static_assert((1.0 + 1.0j) == (1.0 + 0.0j)); // expected-error {{static_assert}}
|
||||
static_assert((1.0 + 1.0j) == (1.0 + 1.0j));
|
||||
static_assert((0.0 + 1.0j) == (1.0 + 1.0j)); // expected-error {{static assertion}}
|
||||
static_assert((0.0 + 1.0j) == (1.0 + 1.0j)); // expected-error {{static_assert}}
|
||||
static_assert((0.0 + 1.0j) == (0.0 + 1.0j));
|
||||
static_assert((-1.0 + 1.0j) == (0.0 + 1.0j)); // expected-error {{static assertion}}
|
||||
static_assert((-1.0 + 1.0j) == (0.0 + 1.0j)); // expected-error {{static_assert}}
|
||||
static_assert((-1.0 + 1.0j) == (-1.0 + 1.0j));
|
||||
static_assert((-1.0 + 0.0j) == (-1.0 + 1.0j)); // expected-error {{static assertion}}
|
||||
static_assert((-1.0 + 0.0j) == (-1.0 + 1.0j)); // expected-error {{static_assert}}
|
||||
static_assert((-1.0 + 0.0j) == (-1.0 + 0.0j));
|
||||
static_assert((-1.0 - 1.0j) == (-1.0 + 0.0j)); // expected-error {{static assertion}}
|
||||
static_assert((-1.0 - 1.0j) == (-1.0 + 0.0j)); // expected-error {{static_assert}}
|
||||
static_assert((-1.0 - 1.0j) == (-1.0 - 1.0j));
|
||||
static_assert((0.0 - 1.0j) == (-1.0 - 1.0j)); // expected-error {{static assertion}}
|
||||
static_assert((0.0 - 1.0j) == (-1.0 - 1.0j)); // expected-error {{static_assert}}
|
||||
static_assert((0.0 - 1.0j) == (0.0 - 1.0j));
|
||||
static_assert((1.0 - 1.0j) == (0.0 - 1.0j)); // expected-error {{static assertion}}
|
||||
static_assert((1.0 - 1.0j) == (0.0 - 1.0j)); // expected-error {{static_assert}}
|
||||
static_assert((1.0 - 1.0j) == (1.0 - 1.0j));
|
||||
|
||||
// Test basic mathematical folding of both complex and real operands.
|
||||
|
|
|
@ -580,7 +580,7 @@ constexpr int fail(const int &p) {
|
|||
return (&p)[64]; // expected-note {{cannot refer to element 64 of array of 2 elements}}
|
||||
}
|
||||
static_assert(fail(*(&(&(*(*&(&zs[2] - 1)[0] + 2 - 2))[2])[-1][2] - 2)) == 11, ""); // \
|
||||
expected-error {{static assertion expression is not an integral constant expression}} \
|
||||
expected-error {{static_assert expression is not an integral constant expression}} \
|
||||
expected-note {{in call to 'fail(zs[1][0][1][0])'}}
|
||||
|
||||
constexpr int arr[40] = { 1, 2, 3, [8] = 4 };
|
||||
|
@ -1596,11 +1596,11 @@ namespace CompoundLiteral {
|
|||
// Matching GCC, file-scope array compound literals initialized by constants
|
||||
// are lifetime-extended.
|
||||
constexpr int *p = (int*)(int[1]){3}; // expected-warning {{C99}}
|
||||
static_assert(*p == 3, ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(*p == 3, ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
// expected-note@-1 {{subexpression not valid}}
|
||||
// expected-note@-3 {{declared here}}
|
||||
static_assert((int[2]){1, 2}[1] == 2, ""); // expected-warning {{C99}}
|
||||
// expected-error@-1 {{static assertion expression is not an integral constant expression}}
|
||||
// expected-error@-1 {{static_assert expression is not an integral constant expression}}
|
||||
// expected-note@-2 {{subexpression not valid}}
|
||||
// expected-note@-3 {{declared here}}
|
||||
|
||||
|
@ -1912,12 +1912,12 @@ namespace VirtualFromBase {
|
|||
static_assert(p->f() == sizeof(X<S1>), "");
|
||||
// cxx11-error@-1 {{not an integral constant expression}}
|
||||
// cxx11-note@-2 {{call to virtual function}}
|
||||
// cxx20_2b-error@-3 {{static assertion failed}}
|
||||
// cxx20_2b-error@-3 {{static_assert failed}}
|
||||
|
||||
// Non-virtual f(), OK.
|
||||
constexpr X<X<S2>> xxs2;
|
||||
constexpr X<S2> *q = const_cast<X<X<S2>>*>(&xxs2);
|
||||
static_assert(q->f() == sizeof(S2), ""); // cxx20_2b-error {{static assertion failed}}
|
||||
static_assert(q->f() == sizeof(S2), ""); // cxx20_2b-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
namespace ConstexprConstructorRecovery {
|
||||
|
|
|
@ -446,7 +446,7 @@ constexpr bool f(bool read_uninit) {
|
|||
}
|
||||
|
||||
static_assert(f(/*read_uninit=*/false), "");
|
||||
static_assert(f(/*read_uninit=*/true), ""); // expected-error{{static assertion expression is not an integral constant expression}} expected-note{{in call to 'f(true)'}}
|
||||
static_assert(f(/*read_uninit=*/true), ""); // expected-error{{static_assert expression is not an integral constant expression}} expected-note{{in call to 'f(true)'}}
|
||||
|
||||
constexpr bytes ld539 = {
|
||||
0x0, 0x0, 0x0, 0x0,
|
||||
|
|
|
@ -68,7 +68,7 @@ constexpr int test9(int x) {
|
|||
}
|
||||
|
||||
constexpr int test10() { return undef(); } // expected-error {{use of undeclared identifier 'undef'}}
|
||||
static_assert(test10() <= 1, "should not crash"); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(test10() <= 1, "should not crash"); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
|
||||
struct X {} array[] = {undef()}; // expected-error {{use of undeclared identifier 'undef'}}
|
||||
constexpr void test11() {
|
||||
|
|
|
@ -1109,8 +1109,8 @@ struct TestType {
|
|||
|
||||
CoroMemberTag test_asserts(int *) const {
|
||||
auto TC = co_yield 0;
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &, int *>, "");
|
||||
}
|
||||
|
||||
|
@ -1201,8 +1201,8 @@ struct DepTestType {
|
|||
|
||||
CoroMemberTag test_asserts(int *) const {
|
||||
auto TC = co_yield 0;
|
||||
static_assert(TC.template MatchesArgs<const DepTestType &>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.template MatchesArgs<const DepTestType &>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.template MatchesArgs<const DepTestType &, int *>, "");
|
||||
}
|
||||
|
||||
|
@ -1265,7 +1265,7 @@ struct DepTestType {
|
|||
static_assert(!TCT::MatchesArgs<DepTestType *>, "");
|
||||
|
||||
// Ensure diagnostics are actually being generated here
|
||||
static_assert(TCT::MatchesArgs<int>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TCT::MatchesArgs<int>, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
static CoroMemberTag test_static(volatile void *const, char &&) {
|
||||
|
|
|
@ -1130,8 +1130,8 @@ struct TestType {
|
|||
|
||||
CoroMemberTag test_asserts(int *) const {
|
||||
auto TC = co_yield 0;
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.MatchesArgs<const TestType &, int *>, "");
|
||||
}
|
||||
|
||||
|
@ -1222,8 +1222,8 @@ struct DepTestType {
|
|||
|
||||
CoroMemberTag test_asserts(int *) const {
|
||||
auto TC = co_yield 0;
|
||||
static_assert(TC.template MatchesArgs<const DepTestType &>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TC.template MatchesArgs<const DepTestType &>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static_assert failed}}
|
||||
static_assert(TC.template MatchesArgs<const DepTestType &, int *>, "");
|
||||
}
|
||||
|
||||
|
@ -1286,7 +1286,7 @@ struct DepTestType {
|
|||
static_assert(!TCT::MatchesArgs<DepTestType *>, "");
|
||||
|
||||
// Ensure diagnostics are actually being generated here
|
||||
static_assert(TCT::MatchesArgs<int>, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(TCT::MatchesArgs<int>, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
static CoroMemberTag test_static(volatile void *const, char &&) {
|
||||
|
|
|
@ -11,19 +11,19 @@ struct DummyTemplate { };
|
|||
|
||||
void func() {
|
||||
auto L0 = []<typename T>(T arg) {
|
||||
static_assert(is_same<T, int>); // expected-error {{static assertion failed}}
|
||||
static_assert(is_same<T, int>); // expected-error {{static_assert failed}}
|
||||
};
|
||||
L0(0);
|
||||
L0(0.0); // expected-note {{in instantiation}}
|
||||
|
||||
auto L1 = []<int I> {
|
||||
static_assert(I == 5); // expected-error {{static assertion failed}}
|
||||
static_assert(I == 5); // expected-error {{static_assert failed}}
|
||||
};
|
||||
L1.operator()<5>();
|
||||
L1.operator()<6>(); // expected-note {{in instantiation}}
|
||||
|
||||
auto L2 = []<template<typename> class T, class U>(T<U> &&arg) {
|
||||
static_assert(is_same<T<U>, DummyTemplate<float>>); // // expected-error {{static assertion failed}}
|
||||
static_assert(is_same<T<U>, DummyTemplate<float>>); // // expected-error {{static_assert failed}}
|
||||
};
|
||||
L2(DummyTemplate<float>());
|
||||
L2(DummyTemplate<double>()); // expected-note {{in instantiation}}
|
||||
|
|
|
@ -152,7 +152,7 @@ __decltype(const_expr) decl_type2 = 0; // ok
|
|||
void no_except() noexcept; // expected-warning {{noexcept specifications are incompatible with C++98}}
|
||||
bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expressions are incompatible with C++98}}
|
||||
void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}}
|
||||
static_assert(true, "!"); // expected-warning {{'static_assert' declarations are incompatible with C++98}}
|
||||
static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}}
|
||||
|
||||
struct InhCtorBase {
|
||||
InhCtorBase(int);
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace ns1 {
|
|||
template<class T> double f(T) = delete; //expected-note{{candidate}}
|
||||
char f(...); //expected-note{{candidate}}
|
||||
|
||||
static_assert(is_same<decltype(f(3)),char>::value, ""); //expected-error{{call to deleted function}} expected-error{{static assertion failed}}
|
||||
static_assert(is_same<decltype(f(3)),char>::value, ""); //expected-error{{call to deleted function}} expected-error{{static_assert failed}}
|
||||
|
||||
template<class T> decltype(f(T{})) g(T); // this one sfinae's out.
|
||||
template<class T> int *g(T);
|
||||
|
|
|
@ -19,4 +19,4 @@ template<typename T> false_type test(...);
|
|||
template<typename T>
|
||||
static const auto has_minus_assign = decltype(test<T>())::value;
|
||||
|
||||
static_assert(has_minus_assign<int*>, "failed"); // expected-error {{static assertion failed due to requirement 'has_minus_assign<int *>': failed}}
|
||||
static_assert(has_minus_assign<int*>, "failed"); // expected-error {{static_assert failed due to requirement 'has_minus_assign<int *>': failed}}
|
||||
|
|
|
@ -149,7 +149,7 @@ enum Circular { // expected-note {{not complete until the closing '}
|
|||
Circular_A = Circular(1), // expected-error {{'test13::Circular' is an incomplete type}}
|
||||
};
|
||||
// Enumerators can be evaluated (they evaluate as zero, but we don't care).
|
||||
static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error {{static_assert failed}}
|
||||
}
|
||||
|
||||
namespace test14 {
|
||||
|
|
|
@ -78,7 +78,7 @@ void func(int sel) {
|
|||
// Using pointers to sizeless data isn't wrong here, but because the
|
||||
// type is incomplete, it doesn't provide any alignment guarantees.
|
||||
_Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
|
||||
_Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
_Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
_Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), "");
|
||||
|
||||
local_int8; // expected-warning {{expression result unused}}
|
||||
|
|
|
@ -22,7 +22,7 @@ inline constexpr bool constexpr_return_false() {
|
|||
template <typename U, typename V>
|
||||
void foo() {
|
||||
static_assert(S1<U, V>::value);
|
||||
// expected-error@-1{{static assertion failed due to requirement 'S1<int, float>::value'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'S1<int, float>::value'}}
|
||||
}
|
||||
template void foo<int, float>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo<int, float>' requested here}}
|
||||
|
@ -30,7 +30,7 @@ template void foo<int, float>();
|
|||
template <typename U, typename V>
|
||||
void foo2() {
|
||||
static_assert(global_inline_var<U, V>);
|
||||
// expected-error@-1{{static assertion failed due to requirement 'global_inline_var<int, float>'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'global_inline_var<int, float>'}}
|
||||
}
|
||||
template void foo2<int, float>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo2<int, float>' requested here}}
|
||||
|
@ -38,7 +38,7 @@ template void foo2<int, float>();
|
|||
template <typename T, typename U, typename V>
|
||||
void foo3() {
|
||||
static_assert(T::template var<U, V>);
|
||||
// expected-error@-1{{static assertion failed due to requirement 'S2<long>::var<int, float>'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'S2<long>::var<int, float>'}}
|
||||
}
|
||||
template void foo3<S2<long>, int, float>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo3<S2<long>, int, float>' requested here}}
|
||||
|
@ -46,7 +46,7 @@ template void foo3<S2<long>, int, float>();
|
|||
template <typename T>
|
||||
void foo4() {
|
||||
static_assert(S1<T[sizeof(T)], int[4]>::value, "");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'S1<float[4], int[4]>::value'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'S1<float[4], int[4]>::value'}}
|
||||
};
|
||||
template void foo4<float>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo4<float>' requested here}}
|
||||
|
@ -55,7 +55,7 @@ template void foo4<float>();
|
|||
template <typename U, typename V>
|
||||
void foo5() {
|
||||
static_assert(!!(global_inline_var<U, V>));
|
||||
// expected-error@-1{{static assertion failed due to requirement '!!(global_inline_var<int, float>)'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '!!(global_inline_var<int, float>)'}}
|
||||
}
|
||||
template void foo5<int, float>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo5<int, float>' requested here}}
|
||||
|
@ -76,29 +76,29 @@ struct X {
|
|||
template <class T>
|
||||
void foo6() {
|
||||
static_assert(X<typename T::T>());
|
||||
// expected-error@-1{{static assertion failed due to requirement 'X<int>()'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'X<int>()'}}
|
||||
static_assert(X<typename T::T>{});
|
||||
// expected-error@-1{{static assertion failed due to requirement 'X<int>{}'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'X<int>{}'}}
|
||||
static_assert(X<typename T::T>{1, 2});
|
||||
// expected-error@-1{{static assertion failed due to requirement 'X<int>{1, 2}'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'X<int>{1, 2}'}}
|
||||
static_assert(X<typename T::T>({1, 2}));
|
||||
// expected-error@-1{{static assertion failed due to requirement 'X<int>({1, 2})'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'X<int>({1, 2})'}}
|
||||
static_assert(typename T::T{0});
|
||||
// expected-error@-1{{static assertion failed due to requirement 'int{0}'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'int{0}'}}
|
||||
static_assert(typename T::T(0));
|
||||
// expected-error@-1{{static assertion failed due to requirement 'int(0)'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'int(0)'}}
|
||||
static_assert(sizeof(X<typename T::T>) == 0);
|
||||
// expected-error@-1{{static assertion failed due to requirement 'sizeof(X<int>) == 0'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'sizeof(X<int>) == 0'}}
|
||||
static_assert((const X<typename T::T> *)nullptr);
|
||||
// expected-error@-1{{static assertion failed due to requirement '(const X<int> *)nullptr'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '(const X<int> *)nullptr'}}
|
||||
static_assert(static_cast<const X<typename T::T> *>(nullptr));
|
||||
// expected-error@-1{{static assertion failed due to requirement 'static_cast<const X<int> *>(nullptr)'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'static_cast<const X<int> *>(nullptr)'}}
|
||||
static_assert((const X<typename T::T>[]){} == nullptr);
|
||||
// expected-error@-1{{static assertion failed due to requirement '(const X<int>[0]){} == nullptr'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '(const X<int>[0]){} == nullptr'}}
|
||||
static_assert(sizeof(X<decltype(X<typename T::T>().X<typename T::T>::~X())>) == 0);
|
||||
// expected-error@-1{{static assertion failed due to requirement 'sizeof(X<void>) == 0'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'sizeof(X<void>) == 0'}}
|
||||
static_assert(constexpr_return_false<typename T::T, typename T::U>());
|
||||
// expected-error@-1{{static assertion failed due to requirement 'constexpr_return_false<int, float>()'}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'constexpr_return_false<int, float>()'}}
|
||||
}
|
||||
template void foo6<ExampleTypes>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo6<ExampleTypes>' requested here}}
|
||||
|
|
|
@ -2,61 +2,61 @@
|
|||
|
||||
int f(); // expected-note {{declared here}}
|
||||
|
||||
static_assert(f(), "f"); // expected-error {{static assertion expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
|
||||
static_assert(f(), "f"); // expected-error {{static_assert expression is not an integral constant expression}} expected-note {{non-constexpr function 'f' cannot be used in a constant expression}}
|
||||
static_assert(true, "true is not false");
|
||||
static_assert(false, "false is false"); // expected-error {{static assertion failed: false is false}}
|
||||
static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
|
||||
|
||||
void g() {
|
||||
static_assert(false, "false is false"); // expected-error {{static assertion failed: false is false}}
|
||||
static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
|
||||
}
|
||||
|
||||
class C {
|
||||
static_assert(false, "false is false"); // expected-error {{static assertion failed: false is false}}
|
||||
static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}}
|
||||
};
|
||||
|
||||
template<int N> struct T {
|
||||
static_assert(N == 2, "N is not 2!"); // expected-error {{static assertion failed due to requirement '1 == 2': N is not 2!}}
|
||||
static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2': N is not 2!}}
|
||||
};
|
||||
|
||||
T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}}
|
||||
T<2> t2;
|
||||
|
||||
template<typename T> struct S {
|
||||
static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static assertion failed due to requirement 'sizeof(char) > sizeof(char)': Type not big enough!}}
|
||||
static_assert(sizeof(T) > sizeof(char), "Type not big enough!"); // expected-error {{static_assert failed due to requirement 'sizeof(char) > sizeof(char)': Type not big enough!}}
|
||||
};
|
||||
|
||||
S<char> s1; // expected-note {{in instantiation of template class 'S<char>' requested here}}
|
||||
S<int> s2;
|
||||
|
||||
static_assert(false, L"\xFFFFFFFF"); // expected-error {{static assertion failed: L"\xFFFFFFFF"}}
|
||||
static_assert(false, u"\U000317FF"); // expected-error {{static assertion failed: u"\U000317FF"}}
|
||||
static_assert(false, L"\xFFFFFFFF"); // expected-error {{static_assert failed: L"\xFFFFFFFF"}}
|
||||
static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed: u"\U000317FF"}}
|
||||
|
||||
static_assert(false, u8"Ω"); // expected-error {{static assertion failed: u8"\316\251"}}
|
||||
static_assert(false, L"\u1234"); // expected-error {{static assertion failed: L"\x1234"}}
|
||||
static_assert(false, L"\x1ff" "0\x123" "fx\xfffff" "goop"); // expected-error {{static assertion failed: L"\x1FF""0\x123""fx\xFFFFFgoop"}}
|
||||
static_assert(false, u8"Ω"); // expected-error {{static_assert failed: u8"\316\251"}}
|
||||
static_assert(false, L"\u1234"); // expected-error {{static_assert failed: L"\x1234"}}
|
||||
static_assert(false, L"\x1ff" "0\x123" "fx\xfffff" "goop"); // expected-error {{static_assert failed: L"\x1FF""0\x123""fx\xFFFFFgoop"}}
|
||||
|
||||
static_assert(false, R"(a
|
||||
\tb
|
||||
c
|
||||
)"); // expected-error@-3 {{static assertion failed: a\n\tb\nc\n}}
|
||||
)"); // expected-error@-3 {{static_assert failed: a\n\tb\nc\n}}
|
||||
|
||||
static_assert(false, "\u0080\u0081\u0082\u0083\u0099\u009A\u009B\u009C\u009D\u009E\u009F");
|
||||
// expected-error@-1 {{static assertion failed: <U+0080><U+0081><U+0082><U+0083><U+0099><U+009A><U+009B><U+009C><U+009D><U+009E><U+009F>}}
|
||||
// expected-error@-1 {{static_assert failed: <U+0080><U+0081><U+0082><U+0083><U+0099><U+009A><U+009B><U+009C><U+009D><U+009E><U+009F>}}
|
||||
|
||||
//! Contains RTL/LTR marks
|
||||
static_assert(false, "\u200Eabc\u200Fdef\u200Fgh"); // expected-error {{static assertion failed: abcdefgh}}
|
||||
static_assert(false, "\u200Eabc\u200Fdef\u200Fgh"); // expected-error {{static_assert failed: abcdefgh}}
|
||||
|
||||
//! Contains ZWJ/regional indicators
|
||||
static_assert(false, "🏳️🌈 🏴 🇪🇺"); // expected-error {{static assertion failed: 🏳️🌈 🏴 🇪🇺}}
|
||||
static_assert(false, "🏳️🌈 🏴 🇪🇺"); // expected-error {{static_assert failed: 🏳️🌈 🏴 🇪🇺}}
|
||||
|
||||
template<typename T> struct AlwaysFails {
|
||||
// Only give one error here.
|
||||
static_assert(false, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(false, ""); // expected-error {{static_assert failed}}
|
||||
};
|
||||
AlwaysFails<int> alwaysFails;
|
||||
|
||||
template<typename T> struct StaticAssertProtected {
|
||||
static_assert(__is_literal(T), ""); // expected-error {{static assertion failed}}
|
||||
static_assert(__is_literal(T), ""); // expected-error {{static_assert failed}}
|
||||
static constexpr T t = {}; // no error here
|
||||
};
|
||||
struct X { ~X(); };
|
||||
|
@ -81,7 +81,7 @@ template<typename T> struct second_trait {
|
|||
static const bool value = false;
|
||||
};
|
||||
|
||||
static_assert(first_trait<X>::value && second_trait<X>::value, "message"); // expected-error{{static assertion failed due to requirement 'second_trait<X>::value': message}}
|
||||
static_assert(first_trait<X>::value && second_trait<X>::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait<X>::value': message}}
|
||||
|
||||
namespace std {
|
||||
|
||||
|
@ -125,29 +125,29 @@ struct ExampleTypes {
|
|||
};
|
||||
|
||||
static_assert(std::is_same<ExampleTypes::T, ExampleTypes::U>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_same<int, float>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_same<int, float>::value': message}}
|
||||
static_assert(std::is_const<ExampleTypes::T>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_const<int>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_const<int>::value': message}}
|
||||
static_assert(!std::is_const<const ExampleTypes::T>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement '!std::is_const<const int>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '!std::is_const<const int>::value': message}}
|
||||
static_assert(!(std::is_const<const ExampleTypes::T>::value), "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement '!(std::is_const<const int>::value)': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '!(std::is_const<const int>::value)': message}}
|
||||
static_assert(std::is_const<const ExampleTypes::T>::value == false, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_const<const int>::value == false': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_const<const int>::value == false': message}}
|
||||
static_assert(!(std::is_const<const ExampleTypes::T>::value == true), "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement '!(std::is_const<const int>::value == true)': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '!(std::is_const<const int>::value == true)': message}}
|
||||
static_assert(std::is_const<ExampleTypes::T>(), "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_const<int>()': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_const<int>()': message}}
|
||||
static_assert(!(std::is_const<const ExampleTypes::T>()()), "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement '!(std::is_const<const int>()())': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '!(std::is_const<const int>()())': message}}
|
||||
static_assert(std::is_same<decltype(std::is_const<const ExampleTypes::T>()), int>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_same<std::is_const<const int>, int>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_same<std::is_const<const int>, int>::value': message}}
|
||||
static_assert(std::is_const<decltype(ExampleTypes::T(3))>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_const<int>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_const<int>::value': message}}
|
||||
static_assert(std::is_const<decltype(ExampleTypes::T())>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_const<int>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_const<int>::value': message}}
|
||||
static_assert(std::is_const<decltype(ExampleTypes(3))>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_const<ExampleTypes>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_const<ExampleTypes>::value': message}}
|
||||
|
||||
struct BI_tag {};
|
||||
struct RAI_tag : BI_tag {};
|
||||
|
@ -160,7 +160,7 @@ struct MyContainer {
|
|||
template <class Container>
|
||||
void foo() {
|
||||
static_assert(std::is_same<RAI_tag, typename Container::iterator::tag>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement 'std::is_same<RAI_tag, BI_tag>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement 'std::is_same<RAI_tag, BI_tag>::value': message}}
|
||||
}
|
||||
template void foo<MyContainer>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo<MyContainer>' requested here}}
|
||||
|
@ -178,7 +178,7 @@ struct NestedTemplates1 {
|
|||
template <typename T, typename U, int a>
|
||||
void foo2() {
|
||||
static_assert(::ns::NestedTemplates1<T, a>::NestedTemplates2::template NestedTemplates3<U>::value, "message");
|
||||
// expected-error@-1{{static assertion failed due to requirement '::ns::NestedTemplates1<int, 3>::NestedTemplates2::NestedTemplates3<float>::value': message}}
|
||||
// expected-error@-1{{static_assert failed due to requirement '::ns::NestedTemplates1<int, 3>::NestedTemplates2::NestedTemplates3<float>::value': message}}
|
||||
}
|
||||
template void foo2<int, float, 3>();
|
||||
// expected-note@-1{{in instantiation of function template specialization 'foo2<int, float, 3>' requested here}}
|
||||
|
@ -186,9 +186,9 @@ template void foo2<int, float, 3>();
|
|||
template <class T>
|
||||
void foo3(T t) {
|
||||
static_assert(std::is_const<T>::value, "message");
|
||||
// expected-error-re@-1{{static assertion failed due to requirement 'std::is_const<(lambda at {{.*}}static-assert.cpp:{{[0-9]*}}:{{[0-9]*}})>::value': message}}
|
||||
// expected-error-re@-1{{static_assert failed due to requirement 'std::is_const<(lambda at {{.*}}static-assert.cpp:{{[0-9]*}}:{{[0-9]*}})>::value': message}}
|
||||
static_assert(std::is_const<decltype(t)>::value, "message");
|
||||
// expected-error-re@-1{{static assertion failed due to requirement 'std::is_const<(lambda at {{.*}}static-assert.cpp:{{[0-9]*}}:{{[0-9]*}})>::value': message}}
|
||||
// expected-error-re@-1{{static_assert failed due to requirement 'std::is_const<(lambda at {{.*}}static-assert.cpp:{{[0-9]*}}:{{[0-9]*}})>::value': message}}
|
||||
}
|
||||
void callFoo3() {
|
||||
foo3([]() {});
|
||||
|
@ -206,12 +206,10 @@ void callFoo4() { foo4(42); }
|
|||
static_assert(42, "message");
|
||||
static_assert(42.0, "message"); // expected-warning {{implicit conversion from 'double' to 'bool' changes value from 42 to true}}
|
||||
constexpr int *p = 0;
|
||||
static_assert(p, "message"); // expected-error {{static assertion failed}}
|
||||
static_assert(p, "message"); // expected-error {{static_assert failed}}
|
||||
|
||||
struct NotBool {
|
||||
} notBool;
|
||||
constexpr NotBool constexprNotBool;
|
||||
static_assert(notBool, "message"); // expected-error {{value of type 'struct NotBool' is not contextually convertible to 'bool'}}
|
||||
static_assert(constexprNotBool, "message"); // expected-error {{value of type 'const NotBool' is not contextually convertible to 'bool'}}
|
||||
|
||||
static_assert(1 , "") // expected-error {{expected ';' after 'static_assert'}}
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace aliastemplateinst {
|
|||
|
||||
namespace DontDiagnoseInvalidTest {
|
||||
template <bool Value> struct Base {
|
||||
static_assert(Value, ""); // expected-error {{static assertion failed}}
|
||||
static_assert(Value, ""); // expected-error {{static_assert failed}}
|
||||
};
|
||||
struct Derived : Base<false> { // expected-note {{requested here}}
|
||||
using Base<false>::Base; // OK. Don't diagnose that 'Base' isn't a base class of Derived.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
extern const int W1 __attribute__((weak)) = 10; // expected-note {{declared here}}
|
||||
|
||||
static_assert(W1 == 10, ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(W1 == 10, ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
// expected-note@-1 {{initializer of weak variable 'W1' is not considered constant because it may be different at runtime}}
|
||||
|
||||
extern const int W2 __attribute__((weak)) = 20;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace InstantiationDependent {
|
|||
static_assert(b<char> == 1, ""); // expected-note {{in instantiation of}} expected-error {{not an integral constant}}
|
||||
|
||||
template<typename T> void f() {
|
||||
static_assert(a<sizeof(sizeof(f(T())))> == 0, ""); // expected-error {{static assertion failed due to requirement 'a<sizeof (sizeof (f(type-parameter-0-0())))> == 0'}}
|
||||
static_assert(a<sizeof(sizeof(f(T())))> == 0, ""); // expected-error {{static_assert failed due to requirement 'a<sizeof (sizeof (f(type-parameter-0-0())))> == 0'}}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ concept Beginable = requires (T t) {
|
|||
// expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
|
||||
};
|
||||
|
||||
static_assert(Beginable<A>); // expected-error {{static assertion failed}}
|
||||
static_assert(Beginable<A>); // expected-error {{static_assert failed}}
|
||||
// expected-note@-1 {{does not satisfy 'Beginable'}}
|
||||
} // namespace PR52905
|
||||
|
||||
|
@ -48,7 +48,7 @@ struct A {
|
|||
static void begin(double);
|
||||
};
|
||||
|
||||
static_assert(C<A>); // expected-error {{static assertion failed}}
|
||||
static_assert(C<A>); // expected-error {{static_assert failed}}
|
||||
// expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
|
||||
|
||||
} // namespace PR52909b
|
||||
|
@ -65,7 +65,7 @@ struct S {
|
|||
int *f() const;
|
||||
};
|
||||
|
||||
static_assert(C<S>); // expected-error {{static assertion failed}}
|
||||
static_assert(C<S>); // expected-error {{static_assert failed}}
|
||||
// expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
|
||||
|
||||
} // namespace PR53075
|
||||
|
|
|
@ -32,7 +32,7 @@ concept C = requires(T t) { t.a.b; };
|
|||
|
||||
static_assert(C<Good>);
|
||||
static_assert(!C<Bad>);
|
||||
static_assert(C<Bad>); // cxx20-error {{static assertion failed}}
|
||||
static_assert(C<Bad>); // cxx20-error {{static_assert failed}}
|
||||
// cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
|
||||
#endif
|
||||
} // namespace DotFollowingFunctionName
|
||||
|
@ -57,7 +57,7 @@ concept C = requires(T t) { t.begin(); };
|
|||
|
||||
static_assert(C<Good>);
|
||||
static_assert(!C<Bad>);
|
||||
static_assert(C<Bad>); // cxx20-error {{static assertion failed}}
|
||||
static_assert(C<Bad>); // cxx20-error {{static_assert failed}}
|
||||
// cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder<Incomplete> *') does not satisfy 'C'}}
|
||||
#endif
|
||||
} // namespace DotFollowingPointer
|
||||
|
|
|
@ -184,7 +184,7 @@ namespace TemplateSpecializations {
|
|||
|
||||
namespace Diags {
|
||||
struct A { int n, m; };
|
||||
template<A a> struct X { static_assert(a.n == a.m); }; // expected-error {{static assertion failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
|
||||
template<A a> struct X { static_assert(a.n == a.m); }; // expected-error {{static_assert failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
|
||||
template struct X<A{1, 2}>; // expected-note {{in instantiation of template class 'Diags::X<{1, 2}>' requested here}}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,12 @@ void pointer_to_incomplete_type() {
|
|||
void function_pointer() {
|
||||
{
|
||||
volatile std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_add(&fun, 0);
|
||||
}
|
||||
{
|
||||
std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_add(&fun, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,12 +49,12 @@ void pointer_to_incomplete_type() {
|
|||
void function_pointer() {
|
||||
{
|
||||
volatile std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed);
|
||||
}
|
||||
{
|
||||
std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_add_explicit(&fun, 0, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,12 +46,12 @@ void pointer_to_incomplete_type() {
|
|||
void function_pointer() {
|
||||
{
|
||||
volatile std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_sub(&fun, 0);
|
||||
}
|
||||
{
|
||||
std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_sub(&fun, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,12 +49,12 @@ void pointer_to_incomplete_type() {
|
|||
void function_pointer() {
|
||||
{
|
||||
volatile std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed);
|
||||
}
|
||||
{
|
||||
std::atomic<void (*)(int)> fun;
|
||||
// expected-error-re@atomic:* {{static assertion failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
// expected-error-re@atomic:* {{static_assert failed due to requirement '!is_function<void (int)>::value'{{.*}}Pointer to function isn't allowed}}
|
||||
std::atomic_fetch_sub_explicit(&fun, 0, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
int main(int, char**)
|
||||
{
|
||||
std::basic_filebuf<char, std::char_traits<wchar_t> > f;
|
||||
// expected-error-re@streambuf:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@streambuf:* {{static_assert failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
int main(int, char**)
|
||||
{
|
||||
std::basic_fstream<char, std::char_traits<wchar_t> > f;
|
||||
// expected-error-re@ios:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@streambuf:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@ios:* {{static_assert failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@streambuf:* {{static_assert failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
|
||||
// FIXME: As of commit r324062 Clang incorrectly generates a diagnostic about mismatching
|
||||
// exception specifications for types which are already invalid for one reason or another.
|
||||
|
|
|
@ -25,7 +25,7 @@ struct test_istream
|
|||
|
||||
int main(int, char**)
|
||||
{
|
||||
// expected-error-re@ios:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@ios:* {{static_assert failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ struct test_ostream
|
|||
|
||||
int main(int, char**)
|
||||
{
|
||||
// expected-error-re@ios:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@ios:* {{static_assert failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
int main(int, char**)
|
||||
{
|
||||
std::basic_stringbuf<char, std::char_traits<wchar_t> > sb;
|
||||
// expected-error-re@streambuf:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@string:* {{static assertion failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@streambuf:* {{static_assert failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
// expected-error-re@string:* {{static_assert failed{{.*}}traits_type::char_type must be the same type as CharT}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
int main(int, char**) {
|
||||
using BadIter = std::reverse_iterator<forward_iterator<int*>>;
|
||||
BadIter i; //expected-error-re@*:* {{static assertion failed{{.*}}reverse_iterator<It> requires It to be a bidirectional iterator.}}
|
||||
BadIter i; //expected-error-re@*:* {{static_assert failed{{.*}}reverse_iterator<It> requires It to be a bidirectional iterator.}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::bernoulli_distribution dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::binomial_distribution<int> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ void test(std::geometric_distribution<int> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 7 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 7 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ void test(std::negative_binomial_distribution<int> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 7 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 7 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::cauchy_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::chi_squared_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 3 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 3 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ void test(std::fisher_f_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 4 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 4 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::lognormal_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::normal_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::student_t_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 5 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 5 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::exponential_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::extreme_value_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::gamma_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 3 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 3 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ void test(std::poisson_distribution<int> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 4 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 4 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::weibull_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::discrete_distribution<int> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::piecewise_constant_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::piecewise_linear_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* 2 {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* 2 {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,6 @@ void test(std::uniform_int_distribution<int> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,6 @@ void test(std::uniform_real_distribution<double> dist)
|
|||
G<int> badg;
|
||||
G<unsigned> okg;
|
||||
|
||||
dist(badg); //expected-error@*:* {{static assertion failed}} //expected-note {{in instantiation}}
|
||||
dist(badg); //expected-error@*:* {{static_assert failed}} //expected-note {{in instantiation}}
|
||||
dist(okg);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ int main(int, char**) {
|
|||
SPtr<3> s3(nullptr, Deleter{}); // OK
|
||||
}
|
||||
|
||||
// expected-error-re@*:* {{static assertion failed{{.*}}default_delete cannot be instantiated for function types}}
|
||||
// expected-error-re@*:* {{static_assert failed{{.*}}default_delete cannot be instantiated for function types}}
|
||||
std::default_delete<FnType<5>> deleter{}; // expected-note {{requested here}}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -19,7 +19,7 @@ int main(int, char**)
|
|||
{
|
||||
typedef std::pair<int, double> P;
|
||||
std::tuple_element<2, P>::type foo; // expected-note {{requested here}}
|
||||
// expected-error-re@*:* {{static assertion failed{{( due to requirement '2U[L]{0,2} < 2')?}}{{.*}}Index out of bounds in std::tuple_element<std::pair<T1, T2>>}}
|
||||
// expected-error-re@*:* {{static_assert failed{{( due to requirement '2U[L]{0,2} < 2')?}}{{.*}}Index out of bounds in std::tuple_element<std::pair<T1, T2>>}}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -30,7 +30,7 @@ int main(int, char**)
|
|||
{
|
||||
typedef std::variant<int, double> T;
|
||||
std::variant_alternative<2, T>::type foo; // expected-note {{requested here}}
|
||||
// expected-error-re@variant:* {{static assertion failed{{( due to requirement '2U[L]{0,2} < sizeof...\(_Types\)')?}}{{.*}}Index out of bounds in std::variant_alternative<>}}
|
||||
// expected-error-re@variant:* {{static_assert failed{{( due to requirement '2U[L]{0,2} < sizeof...\(_Types\)')?}}{{.*}}Index out of bounds in std::variant_alternative<>}}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -33,7 +33,7 @@ template <class PopulationIterator, class SampleIterator> void test() {
|
|||
}
|
||||
|
||||
int main(int, char**) {
|
||||
// expected-error-re@*:* {{static assertion failed{{( due to requirement '.*')?}}{{.*}}SampleIterator must meet the requirements of RandomAccessIterator}}
|
||||
// expected-error-re@*:* {{static_assert failed{{( due to requirement '.*')?}}{{.*}}SampleIterator must meet the requirements of RandomAccessIterator}}
|
||||
// expected-error@*:* 2 {{does not provide a subscript operator}}
|
||||
// expected-error@*:* {{invalid operands}}
|
||||
test<cpp17_input_iterator<int *>, cpp17_output_iterator<int *> >();
|
||||
|
|
|
@ -63,7 +63,7 @@ int main(int, char**)
|
|||
// refuse to rebind the allocator if Allocator::value_type is not exactly what we expect
|
||||
const P arr[] = { {1,1L}, {2,2L}, {3,3L} };
|
||||
std::map m(arr, arr + 3, std::allocator<P>());
|
||||
// expected-error-re@map:* {{static assertion failed{{( due to requirement '.*')?}}{{.*}}Allocator::value_type must be same type as value_type}}
|
||||
// expected-error-re@map:* {{static_assert failed{{( due to requirement '.*')?}}{{.*}}Allocator::value_type must be same type as value_type}}
|
||||
}
|
||||
{
|
||||
// cannot convert from some arbitrary unrelated type
|
||||
|
|
|
@ -63,7 +63,7 @@ int main(int, char**)
|
|||
// refuse to rebind the allocator if Allocator::value_type is not exactly what we expect
|
||||
const P arr[] = { {1,1L}, {2,2L}, {3,3L} };
|
||||
std::multimap m(arr, arr + 3, std::allocator<P>());
|
||||
// expected-error-re@map:* {{static assertion failed{{( due to requirement '.*')?}}{{.*}}Allocator::value_type must be same type as value_type}}
|
||||
// expected-error-re@map:* {{static_assert failed{{( due to requirement '.*')?}}{{.*}}Allocator::value_type must be same type as value_type}}
|
||||
}
|
||||
{
|
||||
// cannot convert from some arbitrary unrelated type
|
||||
|
|
|
@ -18,7 +18,7 @@ int main(int, char**) {
|
|||
typedef double T;
|
||||
typedef std::array<const T, 0> C;
|
||||
C c = {};
|
||||
// expected-error-re@array:* {{static assertion failed{{.*}}cannot fill zero-sized array of type 'const T'}}
|
||||
// expected-error-re@array:* {{static_assert failed{{.*}}cannot fill zero-sized array of type 'const T'}}
|
||||
c.fill(5.5); // expected-note {{requested here}}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ int main(int, char**) {
|
|||
typedef std::array<const T, 0> C;
|
||||
C c = {};
|
||||
C c2 = {};
|
||||
// expected-error-re@array:* {{static assertion failed{{.*}}cannot swap zero-sized array of type 'const T'}}
|
||||
// expected-error-re@array:* {{static_assert failed{{.*}}cannot swap zero-sized array of type 'const T'}}
|
||||
c.swap(c2); // expected-note {{requested here}}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ int main(int, char**)
|
|||
typedef std::array<T, 3> C;
|
||||
C c = {1, 2, 3.5};
|
||||
std::get<3>(c) = 5.5; // expected-note {{requested here}}
|
||||
// expected-error-re@array:* {{static assertion failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::get<> (std::array)}}
|
||||
// expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::get<> (std::array)}}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -19,7 +19,7 @@ int main(int, char**)
|
|||
typedef double T;
|
||||
typedef std::array<T, 3> C;
|
||||
std::tuple_element<3, C> foo; // expected-note {{requested here}}
|
||||
// expected-error-re@array:* {{static assertion failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::tuple_element<> (std::array)}}
|
||||
// expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}}{{.*}}Index out of bounds in std::tuple_element<> (std::array)}}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ int main(int, char**)
|
|||
}
|
||||
{
|
||||
using H = coro::coroutine_handle<int>;
|
||||
// expected-error-re@experimental/coroutine:* 1 {{static assertion failed{{.*}}coroutine_handle<promise_type>::from_address cannot be used with pointers to the coroutine's promise type; use 'from_promise' instead}}
|
||||
// expected-error-re@experimental/coroutine:* 1 {{static_assert failed{{.*}}coroutine_handle<promise_type>::from_address cannot be used with pointers to the coroutine's promise type; use 'from_promise' instead}}
|
||||
H::from_address((const char*)nullptr); // expected-note {{requested here}}
|
||||
// expected-error@experimental/coroutine:* 1 {{coroutine_handle<promise_type>::from_address cannot be called with non-void pointers}}
|
||||
H::from_address((int*)nullptr); // expected-note {{requested here}}
|
||||
|
|
|
@ -26,10 +26,10 @@ int main(int, char**)
|
|||
(void) std::launder(( void *) nullptr);
|
||||
(void) std::launder((const void *) nullptr);
|
||||
(void) std::launder(( volatile void *) nullptr);
|
||||
(void) std::launder((const volatile void *) nullptr); // expected-error-re@new:* 4 {{static assertion failed{{.*}}can't launder cv-void}}
|
||||
(void) std::launder((const volatile void *) nullptr); // expected-error-re@new:* 4 {{static_assert failed{{.*}}can't launder cv-void}}
|
||||
// expected-error@new:* 0-4 {{void pointer argument to '__builtin_launder' is not allowed}}
|
||||
|
||||
(void) std::launder(foo); // expected-error-re@new:* 1 {{static assertion failed{{.*}}can't launder functions}}
|
||||
(void) std::launder(foo); // expected-error-re@new:* 1 {{static_assert failed{{.*}}can't launder functions}}
|
||||
// expected-error@new:* 0-1 {{function pointer argument to '__builtin_launder' is not allowed}}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -34,19 +34,19 @@ constexpr bool toobig()
|
|||
int main(int, char**)
|
||||
{
|
||||
// Make sure we generate a compile-time error for UB
|
||||
static_assert(toobig<unsigned char>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned short>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned long>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned long long>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned char>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned short>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned long>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<unsigned long long>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
|
||||
static_assert(toobig<uint8_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<uint16_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<uint32_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<uint64_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<size_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<uintmax_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<uintptr_t>(), ""); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(toobig<uint8_t>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<uint16_t>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<uint32_t>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<uint64_t>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<size_t>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<uintmax_t>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(toobig<uintptr_t>(), ""); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
// Initializing the primary template is ill-formed.
|
||||
int log2e{std::numbers::log2e_v<
|
||||
int>}; // expected-error-re@numbers:* {{static assertion failed{{.*}}A program that instantiates a primary template of a mathematical constant variable template is ill-formed.}}
|
||||
int>}; // expected-error-re@numbers:* {{static_assert failed{{.*}}A program that instantiates a primary template of a mathematical constant variable template is ill-formed.}}
|
||||
int log10e{std::numbers::log10e_v<int>};
|
||||
int pi{std::numbers::pi_v<int>};
|
||||
int inv_pi{std::numbers::inv_pi_v<int>};
|
||||
|
|
|
@ -19,12 +19,12 @@ int main(int, char**)
|
|||
{
|
||||
typedef unsigned long long T;
|
||||
|
||||
// expected-error-re@*:* {{static assertion failed due to requirement '1ULL == 0 || 1ULL < 1ULL'{{.*}}linear_congruential_engine invalid parameters}}
|
||||
// expected-error-re@*:* {{static_assert failed due to requirement '1ULL == 0 || 1ULL < 1ULL'{{.*}}linear_congruential_engine invalid parameters}}
|
||||
std::linear_congruential_engine<T, 0, 0, 0> e2;
|
||||
// expected-error-re@*:* {{static assertion failed due to requirement '1ULL == 0 || 1ULL < 1ULL'{{.*}}linear_congruential_engine invalid parameters}}
|
||||
// expected-error-re@*:* {{static_assert failed due to requirement '1ULL == 0 || 1ULL < 1ULL'{{.*}}linear_congruential_engine invalid parameters}}
|
||||
std::linear_congruential_engine<T, 0, 1, 1> e3;
|
||||
std::linear_congruential_engine<T, 1, 0, 1> e4;
|
||||
// expected-error-re@*:* {{static assertion failed due to requirement 'is_unsigned<int>::value'{{.*}}_UIntType must be unsigned type}}
|
||||
// expected-error-re@*:* {{static_assert failed due to requirement 'is_unsigned<int>::value'{{.*}}_UIntType must be unsigned type}}
|
||||
std::linear_congruential_engine<int, 0, 0, 0> e5;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -32,20 +32,20 @@ void f() {
|
|||
typedef char C[3];
|
||||
static_assert(std::is_array<C>::value, "");
|
||||
std::basic_string<C, test_traits<C> > s;
|
||||
// expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must not be an array}}
|
||||
// expected-error-re@string:* {{static_assert failed{{.*}}Character type of basic_string must not be an array}}
|
||||
}
|
||||
|
||||
{
|
||||
// not trivial
|
||||
static_assert(!std::is_trivial<NotTrivial>::value, "");
|
||||
std::basic_string<NotTrivial, test_traits<NotTrivial> > s;
|
||||
// expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must be trivial}}
|
||||
// expected-error-re@string:* {{static_assert failed{{.*}}Character type of basic_string must be trivial}}
|
||||
}
|
||||
|
||||
{
|
||||
// not standard layout
|
||||
static_assert(!std::is_standard_layout<NotStandardLayout>::value, "");
|
||||
std::basic_string<NotStandardLayout, test_traits<NotStandardLayout> > s;
|
||||
// expected-error-re@string:* {{static assertion failed{{.*}}Character type of basic_string must be standard-layout}}
|
||||
// expected-error-re@string:* {{static_assert failed{{.*}}Character type of basic_string must be standard-layout}}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,21 +35,21 @@ int main(int, char**)
|
|||
typedef char C[3];
|
||||
static_assert(std::is_array<C>::value, "");
|
||||
std::basic_string_view<C, test_traits<C> > sv;
|
||||
// expected-error-re@string_view:* {{static assertion failed{{.*}}Character type of basic_string_view must not be an array}}
|
||||
// expected-error-re@string_view:* {{static_assert failed{{.*}}Character type of basic_string_view must not be an array}}
|
||||
}
|
||||
|
||||
{
|
||||
// not trivial
|
||||
static_assert(!std::is_trivial<NotTrivial>::value, "");
|
||||
std::basic_string_view<NotTrivial, test_traits<NotTrivial> > sv;
|
||||
// expected-error-re@string_view:* {{static assertion failed{{.*}}Character type of basic_string_view must be trivial}}
|
||||
// expected-error-re@string_view:* {{static_assert failed{{.*}}Character type of basic_string_view must be trivial}}
|
||||
}
|
||||
|
||||
{
|
||||
// not standard layout
|
||||
static_assert(!std::is_standard_layout<NotStandardLayout>::value, "");
|
||||
std::basic_string_view<NotStandardLayout, test_traits<NotStandardLayout> > sv;
|
||||
// expected-error-re@string_view:* {{static assertion failed{{.*}}Character type of basic_string_view must be standard-layout}}
|
||||
// expected-error-re@string_view:* {{static_assert failed{{.*}}Character type of basic_string_view must be standard-layout}}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -21,10 +21,10 @@ struct A {};
|
|||
|
||||
int main(int, char**)
|
||||
{
|
||||
std::chrono::hh_mm_ss<void> h0; // expected-error-re@*:* {{static assertion failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
std::chrono::hh_mm_ss<int> h1; // expected-error-re@*:* {{static assertion failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
std::chrono::hh_mm_ss<std::string> h2; // expected-error-re@*:* {{static assertion failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
std::chrono::hh_mm_ss<A> h3; // expected-error-re@*:* {{static assertion failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
std::chrono::hh_mm_ss<void> h0; // expected-error-re@*:* {{static_assert failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
std::chrono::hh_mm_ss<int> h1; // expected-error-re@*:* {{static_assert failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
std::chrono::hh_mm_ss<std::string> h2; // expected-error-re@*:* {{static_assert failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
std::chrono::hh_mm_ss<A> h3; // expected-error-re@*:* {{static_assert failed{{.*}}template parameter of hh_mm_ss must be a std::chrono::duration}}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ struct TestType {};
|
|||
void test_const_lvalue_cast_request_non_const_lvalue()
|
||||
{
|
||||
const std::any a;
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error@any:* {{drops 'const' qualifier}}
|
||||
std::any_cast<TestType &>(a); // expected-note {{requested here}}
|
||||
|
||||
const std::any a2(42);
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error@any:* {{drops 'const' qualifier}}
|
||||
std::any_cast<int&>(a2); // expected-note {{requested here}}
|
||||
}
|
||||
|
@ -38,22 +38,22 @@ void test_const_lvalue_cast_request_non_const_lvalue()
|
|||
void test_lvalue_any_cast_request_rvalue()
|
||||
{
|
||||
std::any a;
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<TestType &&>(a); // expected-note {{requested here}}
|
||||
|
||||
std::any a2(42);
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<int&&>(a2); // expected-note {{requested here}}
|
||||
}
|
||||
|
||||
void test_rvalue_any_cast_request_lvalue()
|
||||
{
|
||||
std::any a;
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}}
|
||||
// expected-error@any:* {{non-const lvalue reference to type 'TestType' cannot bind to a temporary}}
|
||||
std::any_cast<TestType &>(std::move(a)); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}}
|
||||
// expected-error@any:* {{non-const lvalue reference to type 'int' cannot bind to a temporary}}
|
||||
std::any_cast<int&>(42);
|
||||
}
|
||||
|
|
|
@ -34,16 +34,16 @@ int main(int, char**)
|
|||
{
|
||||
std::any a;
|
||||
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<TestType &>(static_cast<std::any const&>(a)); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<TestType &&>(static_cast<std::any const&>(a)); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<TestType2 &>(static_cast<std::any const&&>(a)); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<TestType2 &&>(static_cast<std::any const&&>(a)); // expected-note {{requested here}}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -48,15 +48,15 @@ struct no_move {
|
|||
|
||||
int main(int, char**) {
|
||||
std::any a;
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be an lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<no_copy>(static_cast<std::any&>(a)); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be a const lvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<no_copy>(static_cast<std::any const&>(a)); // expected-note {{requested here}}
|
||||
|
||||
std::any_cast<no_copy>(static_cast<std::any &&>(a)); // OK
|
||||
|
||||
// expected-error-re@any:* {{static assertion failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}}
|
||||
// expected-error-re@any:* {{static_assert failed{{.*}}ValueType is required to be an rvalue reference or a CopyConstructible type}}
|
||||
std::any_cast<no_move>(static_cast<std::any &&>(a));
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -22,30 +22,30 @@ int main(int, char**)
|
|||
{
|
||||
std::any a = 1;
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int &>(&a); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int &&>(&a); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int const &>(&a); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int const&&>(&a); // expected-note {{requested here}}
|
||||
|
||||
const std::any& a2 = a;
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int &>(&a2); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int &&>(&a2); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int const &>(&a2); // expected-note {{requested here}}
|
||||
|
||||
// expected-error-re@any:* 1 {{static assertion failed{{.*}}_ValueType may not be a reference.}}
|
||||
// expected-error-re@any:* 1 {{static_assert failed{{.*}}_ValueType may not be a reference.}}
|
||||
std::any_cast<int const &&>(&a2); // expected-note {{requested here}}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -25,7 +25,7 @@ constexpr bool test() {
|
|||
}
|
||||
|
||||
int main(int, char**) {
|
||||
// expected-error@+1 {{static assertion expression is not an integral constant expression}}
|
||||
// expected-error@+1 {{static_assert expression is not an integral constant expression}}
|
||||
static_assert(test());
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ int main(int, char**)
|
|||
const int c = 1;
|
||||
|
||||
auto p = std::bind_front(pass, c);
|
||||
static_assert(p() == 1); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(p() == 1); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
|
||||
auto d = std::bind_front(do_nothing, n); // expected-error {{no matching function for call to 'bind_front'}}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ int main(int, char**)
|
|||
#if TEST_HAS_BUILTIN(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
|
||||
MakeSeqT i; // expected-error@*:* {{integer sequences must have non-negative sequence length}}
|
||||
#else
|
||||
MakeSeqT i; // expected-error@*:* {{static assertion failed{{.*}}std::make_integer_sequence must have a non-negative sequence length}}
|
||||
MakeSeqT i; // expected-error@*:* {{static_assert failed{{.*}}std::make_integer_sequence must have a non-negative sequence length}}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -34,7 +34,7 @@ constexpr bool test()
|
|||
|
||||
int main(int, char**)
|
||||
{
|
||||
static_assert(test<double>()); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
LIBCPP_STATIC_ASSERT(test<const double>()); // expected-error {{static assertion expression is not an integral constant expression}}
|
||||
static_assert(test<double>()); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
LIBCPP_STATIC_ASSERT(test<const double>()); // expected-error {{static_assert expression is not an integral constant expression}}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ int main(int, char**)
|
|||
// expected-error@+1 {{no member named 'is_constant_evaluated' in namespace 'std'}}
|
||||
bool b = std::is_constant_evaluated();
|
||||
#else
|
||||
// expected-error@+1 {{static assertion failed}}
|
||||
// expected-error@+1 {{static_assert failed}}
|
||||
static_assert(!std::is_constant_evaluated(), "");
|
||||
// expected-warning@-1 0-1 {{'std::is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
|
||||
#endif
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue