From b7e77ff25fb2412f6ab6d6cc756666b0e2f97bd3 Mon Sep 17 00:00:00 2001 From: Muhammad Usman Shahid Date: Thu, 14 Jul 2022 07:44:51 -0400 Subject: [PATCH] Rewording "static_assert" diagnostics This patch rewords the static assert diagnostic output. Failing a _Static_assert in C should not report that static_assert failed. This changes the wording to be more like GCC and uses "static assertion" when possible instead of hard coding the name. This also changes some instances of 'static_assert' to instead be based on the token in the source code. Differential Revision: https://reviews.llvm.org/D129048 --- .../clang/Basic/DiagnosticParseKinds.td | 4 +- .../clang/Basic/DiagnosticSemaKinds.td | 6 +- clang/include/clang/Parse/Parser.h | 2 +- clang/lib/Parse/ParseDeclCXX.cpp | 7 +- clang/lib/Parse/Parser.cpp | 4 +- clang/test/C/drs/dr0xx.c | 2 +- clang/test/CXX/dcl.dcl/p4-0x.cpp | 2 +- clang/test/CXX/drs/dr19xx.cpp | 2 +- .../CXX/expr/expr.prim/expr.prim.id/p3.cpp | 6 +- .../expr.prim.req/nested-requirement.cpp | 4 +- .../partial-specializations.cpp | 4 +- clang/test/PCH/cxx-static_assert.cpp | 2 +- clang/test/PCH/cxx-templates.cpp | 2 +- clang/test/Parser/objc-static-assert.m | 4 +- clang/test/Parser/objc-static-assert.mm | 14 ++-- clang/test/Sema/builtin-align.c | 4 +- clang/test/Sema/sizeless-1.c | 2 +- clang/test/Sema/static-assert.c | 13 ++-- clang/test/SemaCXX/access-base-class.cpp | 2 +- clang/test/SemaCXX/alias-template.cpp | 2 +- .../SemaCXX/builtin-is-constant-evaluated.cpp | 2 +- clang/test/SemaCXX/builtin-std-move.cpp | 2 +- clang/test/SemaCXX/builtins.cpp | 2 +- clang/test/SemaCXX/complex-folding.cpp | 18 ++--- .../SemaCXX/constant-expression-cxx11.cpp | 10 +-- .../SemaCXX/constexpr-builtin-bit-cast.cpp | 2 +- .../constexpr-function-recovery-crash.cpp | 2 +- .../test/SemaCXX/coroutines-exp-namespace.cpp | 10 +-- clang/test/SemaCXX/coroutines.cpp | 10 +-- clang/test/SemaCXX/cxx2a-template-lambdas.cpp | 6 +- clang/test/SemaCXX/cxx98-compat.cpp | 2 +- .../SemaCXX/delete-and-function-templates.cpp | 2 +- clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp | 2 +- clang/test/SemaCXX/recovery-expr-type.cpp | 2 +- clang/test/SemaCXX/sizeless-1.cpp | 2 +- clang/test/SemaCXX/static-assert-cxx17.cpp | 34 ++++----- clang/test/SemaCXX/static-assert.cpp | 72 ++++++++++--------- clang/test/SemaCXX/using-decl-templates.cpp | 2 +- clang/test/SemaCXX/weak-init.cpp | 2 +- .../SemaTemplate/instantiate-var-template.cpp | 2 +- clang/test/SemaTemplate/pr52909.cpp | 6 +- clang/test/SemaTemplate/pr52970.cpp | 4 +- .../SemaTemplate/temp_arg_nontype_cxx20.cpp | 2 +- 43 files changed, 148 insertions(+), 138 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index 352a050ba5cf..cca251cab801 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -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 static_assert">; + "expected ';' after '%0'">; 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, DefaultIgnore; def ext_ms_static_assert : ExtWarn< "use of 'static_assert' without inclusion of is a Microsoft " diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 550029f58b54..bd02659c9c9d 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -1526,12 +1526,12 @@ def err_messaging_class_with_direct_method : Error< // C++ declarations def err_static_assert_expression_is_not_constant : Error< - "static_assert expression is not an integral constant expression">; + "static assertion 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_assert failed%select{: %1|}0">; +def err_static_assert_failed : Error<"static assertion failed%select{: %1|}0">; def err_static_assert_requirement_failed : Error< - "static_assert failed due to requirement '%0'%select{: %2|}1">; + "static assertion 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">, diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 76e1c9db5284..a9c85ceb434c 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -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); + bool ExpectAndConsumeSemi(unsigned DiagID , StringRef TokenUsed = ""); /// The kind of extra semi diagnostic to emit. enum ExtraSemiKind { diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 143b373e9ea5..9886481e587d 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -926,6 +926,9 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){ assert(Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert) && "Not a static_assert declaration"); + // Save the token used for static assertion. + Token SavedTok = Tok; + if (Tok.is(tok::kw__Static_assert) && !getLangOpts().C11) Diag(Tok, diag::ext_c11_feature) << Tok.getName(); if (Tok.is(tok::kw_static_assert)) { @@ -989,7 +992,9 @@ Decl *Parser::ParseStaticAssertDeclaration(SourceLocation &DeclEnd){ T.consumeClose(); DeclEnd = Tok.getLocation(); - ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert); + // Passing the token used to the error message. + ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, + SavedTok.getName()); return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, AssertExpr.get(), diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index ab8748c2c63d..fd044660845b 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -153,7 +153,7 @@ bool Parser::ExpectAndConsume(tok::TokenKind ExpectedTok, unsigned DiagID, return true; } -bool Parser::ExpectAndConsumeSemi(unsigned DiagID) { +bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed) { if (TryConsumeToken(tok::semi)) return false; @@ -172,7 +172,7 @@ bool Parser::ExpectAndConsumeSemi(unsigned DiagID) { return false; } - return ExpectAndConsume(tok::semi, DiagID); + return ExpectAndConsume(tok::semi, DiagID , TokenUsed); } void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST TST) { diff --git a/clang/test/C/drs/dr0xx.c b/clang/test/C/drs/dr0xx.c index 4f0a505ec4f0..78816011078c 100644 --- a/clang/test/C/drs/dr0xx.c +++ b/clang/test/C/drs/dr0xx.c @@ -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_assert 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 assertion failed due to requirement '__builtin_types_compatible_p(struct S, union U)': fail}} */ /* WG14 DR031: yes * Can constant expressions overflow? diff --git a/clang/test/CXX/dcl.dcl/p4-0x.cpp b/clang/test/CXX/dcl.dcl/p4-0x.cpp index f3988b31df3a..925dea9d471f 100644 --- a/clang/test/CXX/dcl.dcl/p4-0x.cpp +++ b/clang/test/CXX/dcl.dcl/p4-0x.cpp @@ -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_assert failed: L"\024hi!\""}} +static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static assertion failed: L"\024hi!\""}} diff --git a/clang/test/CXX/drs/dr19xx.cpp b/clang/test/CXX/drs/dr19xx.cpp index 38d3ca589eca..08ee2ee77a84 100644 --- a/clang/test/CXX/drs/dr19xx.cpp +++ b/clang/test/CXX/drs/dr19xx.cpp @@ -83,7 +83,7 @@ namespace dr1940 { // dr1940: yes #if __cplusplus >= 201103L static union { static_assert(true, ""); // ok - static_assert(false, ""); // expected-error {{static_assert failed}} + static_assert(false, ""); // expected-error {{static assertion failed}} int not_empty; }; #endif diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp index ed26bcbf6b94..28b5d0adcf05 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp @@ -161,10 +161,10 @@ concept Large = sizeof(T) > 100; struct small { }; static_assert(Large); -// expected-error@-1 {{static_assert failed}} +// expected-error@-1 {{static assertion failed}} // expected-note@-2 {{because 'small' does not satisfy 'Large'}} static_assert(Large, "small isn't large"); -// expected-error@-1 {{static_assert failed: small isn't large}} +// expected-error@-1 {{static assertion 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 concept AccessPrivate = T{}.f; // expected-note@-1{{because substituted constraint expression is ill-formed: 'f' is a private member of 'T4'}} static_assert(AccessPrivate); -// expected-error@-1{{static_assert failed}} +// expected-error@-1{{static assertion failed}} // expected-note@-2{{because 'T4' does not satisfy 'AccessPrivate'}} template diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp index b45b57f6b924..02c1a9dcaf3b 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp @@ -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); // expected-note{{because 'int' does not satisfy 'C2'}} expected-error{{static_assert failed}} -} \ No newline at end of file + static_assert(C2); // expected-note{{because 'int' does not satisfy 'C2'}} expected-error{{static assertion failed}} +} diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp index 7d5c8c40da05..309a434b7fb3 100644 --- a/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp +++ b/clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp @@ -79,6 +79,6 @@ namespace variable_templates // expected-note@-1{{while checking constraint satisfaction for variable template partial specialization 'v1' required here}} // expected-note@-2{{during template argument deduction for variable template partial specialization 'v1' [with T = int *]}} // expected-note@-3{{during template argument deduction for variable template partial specialization 'v1' [with T = int]}} - // expected-error@-4{{static_assert failed due to requirement 'v1'}} + // expected-error@-4{{static assertion failed due to requirement 'v1'}} -} \ No newline at end of file +} diff --git a/clang/test/PCH/cxx-static_assert.cpp b/clang/test/PCH/cxx-static_assert.cpp index d2cf8926a88f..5cbde183bb6d 100644 --- a/clang/test/PCH/cxx-static_assert.cpp +++ b/clang/test/PCH/cxx-static_assert.cpp @@ -17,7 +17,7 @@ template struct T { #else -// expected-error@15 {{static_assert failed due to requirement '1 == 2': N is not 2!}} +// expected-error@15 {{static assertion 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; diff --git a/clang/test/PCH/cxx-templates.cpp b/clang/test/PCH/cxx-templates.cpp index c5694425585d..804c42e6760b 100644 --- a/clang/test/PCH/cxx-templates.cpp +++ b/clang/test/PCH/cxx-templates.cpp @@ -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().f() == 1); // expected-error {{static_assert failed}} + static_assert(A().f() == 1); // expected-error {{static assertion failed}} #endif } diff --git a/clang/test/Parser/objc-static-assert.m b/clang/test/Parser/objc-static-assert.m index 138b4fce2058..b16405787d57 100644 --- a/clang/test/Parser/objc-static-assert.m +++ b/clang/test/Parser/objc-static-assert.m @@ -15,7 +15,7 @@ @interface A { int a; _Static_assert(1, ""); - _Static_assert(0, ""); // expected-error {{static_assert failed}} + _Static_assert(0, ""); // expected-error {{static assertion 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_assert failed}} + _Static_assert(0, ""); // expected-error {{static assertion failed}} } _Static_assert(1, ""); diff --git a/clang/test/Parser/objc-static-assert.mm b/clang/test/Parser/objc-static-assert.mm index 125dd4856a5e..936e484909f5 100644 --- a/clang/test/Parser/objc-static-assert.mm +++ b/clang/test/Parser/objc-static-assert.mm @@ -21,12 +21,12 @@ static_assert(1, ""); _Static_assert(1, ""); - static_assert(0, ""); // expected-error {{static_assert failed}} - _Static_assert(0, ""); // expected-error {{static_assert failed}} + static_assert(0, ""); // expected-error {{static assertion failed}} + _Static_assert(0, ""); // expected-error {{static assertion failed}} - static_assert(a, ""); // expected-error {{static_assert expression is not an integral constant expression}} + static_assert(a, ""); // expected-error {{static assertion expression is not an integral constant expression}} static_assert(sizeof(a) == 4, ""); - static_assert(sizeof(a) == 3, ""); // expected-error {{static_assert failed}} + static_assert(sizeof(a) == 3, ""); // expected-error {{static assertion 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_assert failed}} + static_assert(sizeof(b) == 3, ""); // expected-error {{static assertion 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_assert failed}} + static_assert(sizeof(b) == 3, ""); // expected-error {{static assertion 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_assert failed}} + _Static_assert(0, ""); // expected-error {{static assertion failed}} } @end #endif diff --git a/clang/test/Sema/builtin-align.c b/clang/test/Sema/builtin-align.c index d4cdc230e914..9c73218f70c2 100644 --- a/clang/test/Sema/builtin-align.c +++ b/clang/test/Sema/builtin-align.c @@ -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_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}} + _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}} } // Check that it is a constant expression that can be assigned to globals: diff --git a/clang/test/Sema/sizeless-1.c b/clang/test/Sema/sizeless-1.c index d50d1c629d13..5e7e3be772e8 100644 --- a/clang/test/Sema/sizeless-1.c +++ b/clang/test/Sema/sizeless-1.c @@ -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_assert 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 assertion 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}} diff --git a/clang/test/Sema/static-assert.c b/clang/test/Sema/static-assert.c index 3958aeaaa77e..60a45af3d1d2 100644 --- a/clang/test/Sema/static-assert.c +++ b/clang/test/Sema/static-assert.c @@ -5,11 +5,11 @@ _Static_assert("foo", "string is nonzero"); // ext-warning {{'_Static_assert' is a C11 extension}} #ifndef __cplusplus -// expected-error@-2 {{static_assert expression is not an integral constant expression}} +// expected-error@-2 {{static assertion 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_assert failed: 0 is nonzero}} \ +_Static_assert(0, "0 is nonzero"); // expected-error {{static assertion 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_assert failed: 0 is nonzero}} \ + _Static_assert(0, "0 is nonzero"); // expected-error {{static assertion 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_assert failed: 0 is nonzero}} \ + _Static_assert(0, "0 is nonzero"); // expected-error {{static assertion 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_assert failed due to requirement 'sizeof(char) == sizeof(short)': type size mismatch}} \ +typedef UNION(char, short) U3; // expected-error {{static assertion 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,3 +70,6 @@ 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}} diff --git a/clang/test/SemaCXX/access-base-class.cpp b/clang/test/SemaCXX/access-base-class.cpp index 2ed40ed536c5..8273f2f37838 100644 --- a/clang/test/SemaCXX/access-base-class.cpp +++ b/clang/test/SemaCXX/access-base-class.cpp @@ -109,7 +109,7 @@ class b { template struct Impossible { - static_assert(false, ""); // expected-error {{static_assert failed}} + static_assert(false, ""); // expected-error {{static assertion failed}} }; // verify "no member named 'value'" bogus diagnostic is not emitted. diff --git a/clang/test/SemaCXX/alias-template.cpp b/clang/test/SemaCXX/alias-template.cpp index 0e5d9dae7bb7..c27c79ebd7cb 100644 --- a/clang/test/SemaCXX/alias-template.cpp +++ b/clang/test/SemaCXX/alias-template.cpp @@ -174,7 +174,7 @@ struct S { using T = X[J]; using U = T; }; -static_assert(__is_same(S<3>::U, X[2]), ""); // expected-error {{static_assert failed}} +static_assert(__is_same(S<3>::U, X[2]), ""); // expected-error {{static assertion failed}} } namespace PR39623 { diff --git a/clang/test/SemaCXX/builtin-is-constant-evaluated.cpp b/clang/test/SemaCXX/builtin-is-constant-evaluated.cpp index c54d7c1b7aa8..a1c003c85f73 100644 --- a/clang/test/SemaCXX/builtin-is-constant-evaluated.cpp +++ b/clang/test/SemaCXX/builtin-is-constant-evaluated.cpp @@ -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_assert expression is not an integral constant}} +static_assert(n2 == 42); // expected-error {{static assertion expression is not an integral constant}} // expected-note@-1 {{initializer of 'n2' is not a constant expression}} template diff --git a/clang/test/SemaCXX/builtin-std-move.cpp b/clang/test/SemaCXX/builtin-std-move.cpp index f220be972a35..eb2b85e8e7c7 100644 --- a/clang/test/SemaCXX/builtin-std-move.cpp +++ b/clang/test/SemaCXX/builtin-std-move.cpp @@ -39,7 +39,7 @@ namespace std { return static_cast(x); } template CONSTEXPR T &&forward(typename remove_reference::type &&x) { - static_assert(!is_lvalue_reference::value, "should not forward rval as lval"); // expected-error {{static_assert failed}} + static_assert(!is_lvalue_reference::value, "should not forward rval as lval"); // expected-error {{static assertion failed}} return static_cast(x); } diff --git a/clang/test/SemaCXX/builtins.cpp b/clang/test/SemaCXX/builtins.cpp index 50e0fb42b403..27f9267bbeea 100644 --- a/clang/test/SemaCXX/builtins.cpp +++ b/clang/test/SemaCXX/builtins.cpp @@ -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_assert expression is not an integral constant expression}} +static_assert(__builtin_function_start(a) == a, ""); // expected-error {{static assertion expression is not an integral constant expression}} } // namespace function_start void no_ms_builtins() { diff --git a/clang/test/SemaCXX/complex-folding.cpp b/clang/test/SemaCXX/complex-folding.cpp index 1c2f9c73eb31..8c56cf0e5d98 100644 --- a/clang/test/SemaCXX/complex-folding.cpp +++ b/clang/test/SemaCXX/complex-folding.cpp @@ -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_assert}} +static_assert((0.0 + 0.0j) != (0.0 + 0.0j)); // expected-error {{static assertion}} 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_assert}} +static_assert((1.0 + 0.0j) == (0.0 + 0.0j)); // expected-error {{static assertion}} static_assert((1.0 + 0.0j) == (1.0 + 0.0j)); -static_assert((1.0 + 1.0j) == (1.0 + 0.0j)); // expected-error {{static_assert}} +static_assert((1.0 + 1.0j) == (1.0 + 0.0j)); // expected-error {{static assertion}} static_assert((1.0 + 1.0j) == (1.0 + 1.0j)); -static_assert((0.0 + 1.0j) == (1.0 + 1.0j)); // expected-error {{static_assert}} +static_assert((0.0 + 1.0j) == (1.0 + 1.0j)); // expected-error {{static assertion}} static_assert((0.0 + 1.0j) == (0.0 + 1.0j)); -static_assert((-1.0 + 1.0j) == (0.0 + 1.0j)); // expected-error {{static_assert}} +static_assert((-1.0 + 1.0j) == (0.0 + 1.0j)); // expected-error {{static assertion}} static_assert((-1.0 + 1.0j) == (-1.0 + 1.0j)); -static_assert((-1.0 + 0.0j) == (-1.0 + 1.0j)); // expected-error {{static_assert}} +static_assert((-1.0 + 0.0j) == (-1.0 + 1.0j)); // expected-error {{static assertion}} static_assert((-1.0 + 0.0j) == (-1.0 + 0.0j)); -static_assert((-1.0 - 1.0j) == (-1.0 + 0.0j)); // expected-error {{static_assert}} +static_assert((-1.0 - 1.0j) == (-1.0 + 0.0j)); // expected-error {{static assertion}} static_assert((-1.0 - 1.0j) == (-1.0 - 1.0j)); -static_assert((0.0 - 1.0j) == (-1.0 - 1.0j)); // expected-error {{static_assert}} +static_assert((0.0 - 1.0j) == (-1.0 - 1.0j)); // expected-error {{static assertion}} static_assert((0.0 - 1.0j) == (0.0 - 1.0j)); -static_assert((1.0 - 1.0j) == (0.0 - 1.0j)); // expected-error {{static_assert}} +static_assert((1.0 - 1.0j) == (0.0 - 1.0j)); // expected-error {{static assertion}} static_assert((1.0 - 1.0j) == (1.0 - 1.0j)); // Test basic mathematical folding of both complex and real operands. diff --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp b/clang/test/SemaCXX/constant-expression-cxx11.cpp index b03cb7696aae..aaca34cd6583 100644 --- a/clang/test/SemaCXX/constant-expression-cxx11.cpp +++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -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_assert expression is not an integral constant expression}} \ +expected-error {{static assertion 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_assert expression is not an integral constant expression}} + static_assert(*p == 3, ""); // expected-error {{static assertion 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_assert expression is not an integral constant expression}} + // expected-error@-1 {{static assertion 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), ""); // cxx11-error@-1 {{not an integral constant expression}} // cxx11-note@-2 {{call to virtual function}} - // cxx20_2b-error@-3 {{static_assert failed}} + // cxx20_2b-error@-3 {{static assertion failed}} // Non-virtual f(), OK. constexpr X> xxs2; constexpr X *q = const_cast>*>(&xxs2); - static_assert(q->f() == sizeof(S2), ""); // cxx20_2b-error {{static_assert failed}} + static_assert(q->f() == sizeof(S2), ""); // cxx20_2b-error {{static assertion failed}} } namespace ConstexprConstructorRecovery { diff --git a/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp b/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp index cb1812905d3d..36ced2e298c6 100644 --- a/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp +++ b/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp @@ -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_assert expression is not an integral constant expression}} expected-note{{in call to 'f(true)'}} +static_assert(f(/*read_uninit=*/true), ""); // expected-error{{static assertion expression is not an integral constant expression}} expected-note{{in call to 'f(true)'}} constexpr bytes ld539 = { 0x0, 0x0, 0x0, 0x0, diff --git a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp index 77e22a911cb4..07bc5e57ae13 100644 --- a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp +++ b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp @@ -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_assert expression is not an integral constant expression}} +static_assert(test10() <= 1, "should not crash"); // expected-error {{static assertion expression is not an integral constant expression}} struct X {} array[] = {undef()}; // expected-error {{use of undeclared identifier 'undef'}} constexpr void test11() { diff --git a/clang/test/SemaCXX/coroutines-exp-namespace.cpp b/clang/test/SemaCXX/coroutines-exp-namespace.cpp index 534d47dfa776..48f0dd012634 100644 --- a/clang/test/SemaCXX/coroutines-exp-namespace.cpp +++ b/clang/test/SemaCXX/coroutines-exp-namespace.cpp @@ -1109,8 +1109,8 @@ struct TestType { CoroMemberTag test_asserts(int *) const { auto TC = co_yield 0; - static_assert(TC.MatchesArgs, ""); // expected-error {{static_assert failed}} - static_assert(TC.MatchesArgs, ""); // expected-error {{static_assert failed}} + static_assert(TC.MatchesArgs, ""); // expected-error {{static assertion failed}} + static_assert(TC.MatchesArgs, ""); // expected-error {{static assertion failed}} static_assert(TC.MatchesArgs, ""); } @@ -1201,8 +1201,8 @@ struct DepTestType { CoroMemberTag test_asserts(int *) const { auto TC = co_yield 0; - static_assert(TC.template MatchesArgs, ""); // expected-error {{static_assert failed}} - static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static_assert failed}} + static_assert(TC.template MatchesArgs, ""); // expected-error {{static assertion failed}} + static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static assertion failed}} static_assert(TC.template MatchesArgs, ""); } @@ -1265,7 +1265,7 @@ struct DepTestType { static_assert(!TCT::MatchesArgs, ""); // Ensure diagnostics are actually being generated here - static_assert(TCT::MatchesArgs, ""); // expected-error {{static_assert failed}} + static_assert(TCT::MatchesArgs, ""); // expected-error {{static assertion failed}} } static CoroMemberTag test_static(volatile void *const, char &&) { diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp index 5d6ef7f73cfd..b646810809a0 100644 --- a/clang/test/SemaCXX/coroutines.cpp +++ b/clang/test/SemaCXX/coroutines.cpp @@ -1130,8 +1130,8 @@ struct TestType { CoroMemberTag test_asserts(int *) const { auto TC = co_yield 0; - static_assert(TC.MatchesArgs, ""); // expected-error {{static_assert failed}} - static_assert(TC.MatchesArgs, ""); // expected-error {{static_assert failed}} + static_assert(TC.MatchesArgs, ""); // expected-error {{static assertion failed}} + static_assert(TC.MatchesArgs, ""); // expected-error {{static assertion failed}} static_assert(TC.MatchesArgs, ""); } @@ -1222,8 +1222,8 @@ struct DepTestType { CoroMemberTag test_asserts(int *) const { auto TC = co_yield 0; - static_assert(TC.template MatchesArgs, ""); // expected-error {{static_assert failed}} - static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static_assert failed}} + static_assert(TC.template MatchesArgs, ""); // expected-error {{static assertion failed}} + static_assert(TC.template MatchesArgs<>, ""); // expected-error {{static assertion failed}} static_assert(TC.template MatchesArgs, ""); } @@ -1286,7 +1286,7 @@ struct DepTestType { static_assert(!TCT::MatchesArgs, ""); // Ensure diagnostics are actually being generated here - static_assert(TCT::MatchesArgs, ""); // expected-error {{static_assert failed}} + static_assert(TCT::MatchesArgs, ""); // expected-error {{static assertion failed}} } static CoroMemberTag test_static(volatile void *const, char &&) { diff --git a/clang/test/SemaCXX/cxx2a-template-lambdas.cpp b/clang/test/SemaCXX/cxx2a-template-lambdas.cpp index 6d22be44d836..65baf29718f0 100644 --- a/clang/test/SemaCXX/cxx2a-template-lambdas.cpp +++ b/clang/test/SemaCXX/cxx2a-template-lambdas.cpp @@ -11,19 +11,19 @@ struct DummyTemplate { }; void func() { auto L0 = [](T arg) { - static_assert(is_same); // expected-error {{static_assert failed}} + static_assert(is_same); // expected-error {{static assertion failed}} }; L0(0); L0(0.0); // expected-note {{in instantiation}} auto L1 = [] { - static_assert(I == 5); // expected-error {{static_assert failed}} + static_assert(I == 5); // expected-error {{static assertion failed}} }; L1.operator()<5>(); L1.operator()<6>(); // expected-note {{in instantiation}} auto L2 = [] class T, class U>(T &&arg) { - static_assert(is_same, DummyTemplate>); // // expected-error {{static_assert failed}} + static_assert(is_same, DummyTemplate>); // // expected-error {{static assertion failed}} }; L2(DummyTemplate()); L2(DummyTemplate()); // expected-note {{in instantiation}} diff --git a/clang/test/SemaCXX/cxx98-compat.cpp b/clang/test/SemaCXX/cxx98-compat.cpp index 581b620c7072..f12d7c2d3f05 100644 --- a/clang/test/SemaCXX/cxx98-compat.cpp +++ b/clang/test/SemaCXX/cxx98-compat.cpp @@ -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); diff --git a/clang/test/SemaCXX/delete-and-function-templates.cpp b/clang/test/SemaCXX/delete-and-function-templates.cpp index 22e95cb7937a..0232b5bc6f12 100644 --- a/clang/test/SemaCXX/delete-and-function-templates.cpp +++ b/clang/test/SemaCXX/delete-and-function-templates.cpp @@ -12,7 +12,7 @@ namespace ns1 { template double f(T) = delete; //expected-note{{candidate}} char f(...); //expected-note{{candidate}} -static_assert(is_same::value, ""); //expected-error{{call to deleted function}} expected-error{{static_assert failed}} +static_assert(is_same::value, ""); //expected-error{{call to deleted function}} expected-error{{static assertion failed}} template decltype(f(T{})) g(T); // this one sfinae's out. template int *g(T); diff --git a/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp b/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp index a3a38d42818b..736c09d68b52 100644 --- a/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp +++ b/clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp @@ -19,4 +19,4 @@ template false_type test(...); template static const auto has_minus_assign = decltype(test())::value; -static_assert(has_minus_assign, "failed"); // expected-error {{static_assert failed due to requirement 'has_minus_assign': failed}} +static_assert(has_minus_assign, "failed"); // expected-error {{static assertion failed due to requirement 'has_minus_assign': failed}} diff --git a/clang/test/SemaCXX/recovery-expr-type.cpp b/clang/test/SemaCXX/recovery-expr-type.cpp index 3db11466529e..920cf35fee15 100644 --- a/clang/test/SemaCXX/recovery-expr-type.cpp +++ b/clang/test/SemaCXX/recovery-expr-type.cpp @@ -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_assert failed}} +static_assert(Circular_A == 0 && Circular_A != 0, ""); // expected-error {{static assertion failed}} } namespace test14 { diff --git a/clang/test/SemaCXX/sizeless-1.cpp b/clang/test/SemaCXX/sizeless-1.cpp index 5986be91233f..80e74db49c0f 100644 --- a/clang/test/SemaCXX/sizeless-1.cpp +++ b/clang/test/SemaCXX/sizeless-1.cpp @@ -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_assert 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 assertion 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}} diff --git a/clang/test/SemaCXX/static-assert-cxx17.cpp b/clang/test/SemaCXX/static-assert-cxx17.cpp index ce9826795d5d..888117d9f27c 100644 --- a/clang/test/SemaCXX/static-assert-cxx17.cpp +++ b/clang/test/SemaCXX/static-assert-cxx17.cpp @@ -22,7 +22,7 @@ inline constexpr bool constexpr_return_false() { template void foo() { static_assert(S1::value); - // expected-error@-1{{static_assert failed due to requirement 'S1::value'}} + // expected-error@-1{{static assertion failed due to requirement 'S1::value'}} } template void foo(); // expected-note@-1{{in instantiation of function template specialization 'foo' requested here}} @@ -30,7 +30,7 @@ template void foo(); template void foo2() { static_assert(global_inline_var); - // expected-error@-1{{static_assert failed due to requirement 'global_inline_var'}} + // expected-error@-1{{static assertion failed due to requirement 'global_inline_var'}} } template void foo2(); // expected-note@-1{{in instantiation of function template specialization 'foo2' requested here}} @@ -38,7 +38,7 @@ template void foo2(); template void foo3() { static_assert(T::template var); - // expected-error@-1{{static_assert failed due to requirement 'S2::var'}} + // expected-error@-1{{static assertion failed due to requirement 'S2::var'}} } template void foo3, int, float>(); // expected-note@-1{{in instantiation of function template specialization 'foo3, int, float>' requested here}} @@ -46,7 +46,7 @@ template void foo3, int, float>(); template void foo4() { static_assert(S1::value, ""); - // expected-error@-1{{static_assert failed due to requirement 'S1::value'}} + // expected-error@-1{{static assertion failed due to requirement 'S1::value'}} }; template void foo4(); // expected-note@-1{{in instantiation of function template specialization 'foo4' requested here}} @@ -55,7 +55,7 @@ template void foo4(); template void foo5() { static_assert(!!(global_inline_var)); - // expected-error@-1{{static_assert failed due to requirement '!!(global_inline_var)'}} + // expected-error@-1{{static assertion failed due to requirement '!!(global_inline_var)'}} } template void foo5(); // expected-note@-1{{in instantiation of function template specialization 'foo5' requested here}} @@ -76,29 +76,29 @@ struct X { template void foo6() { static_assert(X()); - // expected-error@-1{{static_assert failed due to requirement 'X()'}} + // expected-error@-1{{static assertion failed due to requirement 'X()'}} static_assert(X{}); - // expected-error@-1{{static_assert failed due to requirement 'X{}'}} + // expected-error@-1{{static assertion failed due to requirement 'X{}'}} static_assert(X{1, 2}); - // expected-error@-1{{static_assert failed due to requirement 'X{1, 2}'}} + // expected-error@-1{{static assertion failed due to requirement 'X{1, 2}'}} static_assert(X({1, 2})); - // expected-error@-1{{static_assert failed due to requirement 'X({1, 2})'}} + // expected-error@-1{{static assertion failed due to requirement 'X({1, 2})'}} static_assert(typename T::T{0}); - // expected-error@-1{{static_assert failed due to requirement 'int{0}'}} + // expected-error@-1{{static assertion failed due to requirement 'int{0}'}} static_assert(typename T::T(0)); - // expected-error@-1{{static_assert failed due to requirement 'int(0)'}} + // expected-error@-1{{static assertion failed due to requirement 'int(0)'}} static_assert(sizeof(X) == 0); - // expected-error@-1{{static_assert failed due to requirement 'sizeof(X) == 0'}} + // expected-error@-1{{static assertion failed due to requirement 'sizeof(X) == 0'}} static_assert((const X *)nullptr); - // expected-error@-1{{static_assert failed due to requirement '(const X *)nullptr'}} + // expected-error@-1{{static assertion failed due to requirement '(const X *)nullptr'}} static_assert(static_cast *>(nullptr)); - // expected-error@-1{{static_assert failed due to requirement 'static_cast *>(nullptr)'}} + // expected-error@-1{{static assertion failed due to requirement 'static_cast *>(nullptr)'}} static_assert((const X[]){} == nullptr); - // expected-error@-1{{static_assert failed due to requirement '(const X[0]){} == nullptr'}} + // expected-error@-1{{static assertion failed due to requirement '(const X[0]){} == nullptr'}} static_assert(sizeof(X().X::~X())>) == 0); - // expected-error@-1{{static_assert failed due to requirement 'sizeof(X) == 0'}} + // expected-error@-1{{static assertion failed due to requirement 'sizeof(X) == 0'}} static_assert(constexpr_return_false()); - // expected-error@-1{{static_assert failed due to requirement 'constexpr_return_false()'}} + // expected-error@-1{{static assertion failed due to requirement 'constexpr_return_false()'}} } template void foo6(); // expected-note@-1{{in instantiation of function template specialization 'foo6' requested here}} diff --git a/clang/test/SemaCXX/static-assert.cpp b/clang/test/SemaCXX/static-assert.cpp index 2ac0dfdea9ea..7e1ffb325a1b 100644 --- a/clang/test/SemaCXX/static-assert.cpp +++ b/clang/test/SemaCXX/static-assert.cpp @@ -2,61 +2,61 @@ int f(); // expected-note {{declared here}} -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(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(true, "true is not false"); -static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}} +static_assert(false, "false is false"); // expected-error {{static assertion failed: false is false}} void g() { - static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}} + static_assert(false, "false is false"); // expected-error {{static assertion failed: false is false}} } class C { - static_assert(false, "false is false"); // expected-error {{static_assert failed: false is false}} + static_assert(false, "false is false"); // expected-error {{static assertion failed: false is false}} }; template struct T { - static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed due to requirement '1 == 2': N is not 2!}} + static_assert(N == 2, "N is not 2!"); // expected-error {{static assertion 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 struct S { - 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!}} + 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!}} }; S s1; // expected-note {{in instantiation of template class 'S' requested here}} S s2; -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, L"\xFFFFFFFF"); // expected-error {{static assertion failed: L"\xFFFFFFFF"}} +static_assert(false, u"\U000317FF"); // expected-error {{static assertion failed: u"\U000317FF"}} -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, 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, R"(a \tb c -)"); // expected-error@-3 {{static_assert failed: a\n\tb\nc\n}} +)"); // expected-error@-3 {{static assertion failed: a\n\tb\nc\n}} static_assert(false, "\u0080\u0081\u0082\u0083\u0099\u009A\u009B\u009C\u009D\u009E\u009F"); -// expected-error@-1 {{static_assert failed: }} +// expected-error@-1 {{static assertion failed: }} //! Contains RTL/LTR marks -static_assert(false, "\u200Eabc\u200Fdef\u200Fgh"); // expected-error {{static_assert failed: ‎abc‏def‏gh}} +static_assert(false, "\u200Eabc\u200Fdef\u200Fgh"); // expected-error {{static assertion failed: ‎abc‏def‏gh}} //! Contains ZWJ/regional indicators -static_assert(false, "🏳️‍🌈 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🇪🇺"); // expected-error {{static_assert failed: 🏳️‍🌈 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🇪🇺}} +static_assert(false, "🏳️‍🌈 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🇪🇺"); // expected-error {{static assertion failed: 🏳️‍🌈 🏴󠁧󠁢󠁥󠁮󠁧󠁿 🇪🇺}} template struct AlwaysFails { // Only give one error here. - static_assert(false, ""); // expected-error {{static_assert failed}} + static_assert(false, ""); // expected-error {{static assertion failed}} }; AlwaysFails alwaysFails; template struct StaticAssertProtected { - static_assert(__is_literal(T), ""); // expected-error {{static_assert failed}} + static_assert(__is_literal(T), ""); // expected-error {{static assertion failed}} static constexpr T t = {}; // no error here }; struct X { ~X(); }; @@ -81,7 +81,7 @@ template struct second_trait { static const bool value = false; }; -static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static_assert failed due to requirement 'second_trait::value': message}} +static_assert(first_trait::value && second_trait::value, "message"); // expected-error{{static assertion failed due to requirement 'second_trait::value': message}} namespace std { @@ -125,29 +125,29 @@ struct ExampleTypes { }; static_assert(std::is_same::value, "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_same::value': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_same::value': message}} static_assert(std::is_const::value, "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_const::value': message}} static_assert(!std::is_const::value, "message"); -// expected-error@-1{{static_assert failed due to requirement '!std::is_const::value': message}} +// expected-error@-1{{static assertion failed due to requirement '!std::is_const::value': message}} static_assert(!(std::is_const::value), "message"); -// expected-error@-1{{static_assert failed due to requirement '!(std::is_const::value)': message}} +// expected-error@-1{{static assertion failed due to requirement '!(std::is_const::value)': message}} static_assert(std::is_const::value == false, "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value == false': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_const::value == false': message}} static_assert(!(std::is_const::value == true), "message"); -// expected-error@-1{{static_assert failed due to requirement '!(std::is_const::value == true)': message}} +// expected-error@-1{{static assertion failed due to requirement '!(std::is_const::value == true)': message}} static_assert(std::is_const(), "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_const()': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_const()': message}} static_assert(!(std::is_const()()), "message"); -// expected-error@-1{{static_assert failed due to requirement '!(std::is_const()())': message}} +// expected-error@-1{{static assertion failed due to requirement '!(std::is_const()())': message}} static_assert(std::is_same()), int>::value, "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_same, int>::value': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_same, int>::value': message}} static_assert(std::is_const::value, "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_const::value': message}} static_assert(std::is_const::value, "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_const::value': message}} static_assert(std::is_const::value, "message"); -// expected-error@-1{{static_assert failed due to requirement 'std::is_const::value': message}} +// expected-error@-1{{static assertion failed due to requirement 'std::is_const::value': message}} struct BI_tag {}; struct RAI_tag : BI_tag {}; @@ -160,7 +160,7 @@ struct MyContainer { template void foo() { static_assert(std::is_same::value, "message"); - // expected-error@-1{{static_assert failed due to requirement 'std::is_same::value': message}} + // expected-error@-1{{static assertion failed due to requirement 'std::is_same::value': message}} } template void foo(); // expected-note@-1{{in instantiation of function template specialization 'foo' requested here}} @@ -178,7 +178,7 @@ struct NestedTemplates1 { template void foo2() { static_assert(::ns::NestedTemplates1::NestedTemplates2::template NestedTemplates3::value, "message"); - // expected-error@-1{{static_assert failed due to requirement '::ns::NestedTemplates1::NestedTemplates2::NestedTemplates3::value': message}} + // expected-error@-1{{static assertion failed due to requirement '::ns::NestedTemplates1::NestedTemplates2::NestedTemplates3::value': message}} } template void foo2(); // expected-note@-1{{in instantiation of function template specialization 'foo2' requested here}} @@ -186,9 +186,9 @@ template void foo2(); template void foo3(T t) { static_assert(std::is_const::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}} + // expected-error-re@-1{{static assertion failed due to requirement 'std::is_const<(lambda at {{.*}}static-assert.cpp:{{[0-9]*}}:{{[0-9]*}})>::value': message}} static_assert(std::is_const::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}} + // expected-error-re@-1{{static assertion failed due to requirement 'std::is_const<(lambda at {{.*}}static-assert.cpp:{{[0-9]*}}:{{[0-9]*}})>::value': message}} } void callFoo3() { foo3([]() {}); @@ -206,10 +206,12 @@ 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_assert failed}} +static_assert(p, "message"); // expected-error {{static assertion 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'}} diff --git a/clang/test/SemaCXX/using-decl-templates.cpp b/clang/test/SemaCXX/using-decl-templates.cpp index d825971954ec..73d9bc3e774c 100644 --- a/clang/test/SemaCXX/using-decl-templates.cpp +++ b/clang/test/SemaCXX/using-decl-templates.cpp @@ -95,7 +95,7 @@ namespace aliastemplateinst { namespace DontDiagnoseInvalidTest { template struct Base { - static_assert(Value, ""); // expected-error {{static_assert failed}} + static_assert(Value, ""); // expected-error {{static assertion failed}} }; struct Derived : Base { // expected-note {{requested here}} using Base::Base; // OK. Don't diagnose that 'Base' isn't a base class of Derived. diff --git a/clang/test/SemaCXX/weak-init.cpp b/clang/test/SemaCXX/weak-init.cpp index c040330bb274..a88d32bdca5a 100644 --- a/clang/test/SemaCXX/weak-init.cpp +++ b/clang/test/SemaCXX/weak-init.cpp @@ -2,7 +2,7 @@ extern const int W1 __attribute__((weak)) = 10; // expected-note {{declared here}} -static_assert(W1 == 10, ""); // expected-error {{static_assert expression is not an integral constant expression}} +static_assert(W1 == 10, ""); // expected-error {{static assertion 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; diff --git a/clang/test/SemaTemplate/instantiate-var-template.cpp b/clang/test/SemaTemplate/instantiate-var-template.cpp index 8037a4865a8b..89c4a65249cc 100644 --- a/clang/test/SemaTemplate/instantiate-var-template.cpp +++ b/clang/test/SemaTemplate/instantiate-var-template.cpp @@ -31,7 +31,7 @@ namespace InstantiationDependent { static_assert(b == 1, ""); // expected-note {{in instantiation of}} expected-error {{not an integral constant}} template void f() { - static_assert(a == 0, ""); // expected-error {{static_assert failed due to requirement 'a == 0'}} + static_assert(a == 0, ""); // expected-error {{static assertion failed due to requirement 'a == 0'}} } } diff --git a/clang/test/SemaTemplate/pr52909.cpp b/clang/test/SemaTemplate/pr52909.cpp index a17ede44fce0..b06c97c3cb67 100644 --- a/clang/test/SemaTemplate/pr52909.cpp +++ b/clang/test/SemaTemplate/pr52909.cpp @@ -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); // expected-error {{static_assert failed}} +static_assert(Beginable); // expected-error {{static assertion failed}} // expected-note@-1 {{does not satisfy 'Beginable'}} } // namespace PR52905 @@ -48,7 +48,7 @@ struct A { static void begin(double); }; -static_assert(C); // expected-error {{static_assert failed}} +static_assert(C); // expected-error {{static assertion 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); // expected-error {{static_assert failed}} +static_assert(C); // expected-error {{static assertion failed}} // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}} } // namespace PR53075 diff --git a/clang/test/SemaTemplate/pr52970.cpp b/clang/test/SemaTemplate/pr52970.cpp index 7585fba41208..e7d5fc601221 100644 --- a/clang/test/SemaTemplate/pr52970.cpp +++ b/clang/test/SemaTemplate/pr52970.cpp @@ -32,7 +32,7 @@ concept C = requires(T t) { t.a.b; }; static_assert(C); static_assert(!C); -static_assert(C); // cxx20-error {{static_assert failed}} +static_assert(C); // cxx20-error {{static assertion 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); static_assert(!C); -static_assert(C); // cxx20-error {{static_assert failed}} +static_assert(C); // cxx20-error {{static assertion failed}} // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}} #endif } // namespace DotFollowingPointer diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp index ad9cfc7cdd9d..feb9bcde9273 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp @@ -184,7 +184,7 @@ namespace TemplateSpecializations { namespace Diags { struct A { int n, m; }; - template 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 { 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 struct X; // expected-note {{in instantiation of template class 'Diags::X<{1, 2}>' requested here}} }