Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -425,6 +425,9 @@ - ``-Wformat`` will no longer suggest a no-op fix-it for fixing scoped enum format warnings. Instead, it will suggest casting the enum object to the type specified in the format string. +- When describing the failure of static assertion, clang prints the integer representation + of the value instead of its character representation even when the user-provided value + is of character type so as not to output non-printable characters. Bug Fixes in This Version ------------------------- Index: clang/lib/Sema/SemaDeclCXX.cpp =================================================================== --- clang/lib/Sema/SemaDeclCXX.cpp +++ clang/lib/Sema/SemaDeclCXX.cpp @@ -16866,8 +16866,14 @@ Expr::EvalResult Result; SmallString<12> ValueString; bool Print; - } DiagSide[2] = {{LHS, Expr::EvalResult(), {}, false}, - {RHS, Expr::EvalResult(), {}, false}}; + } DiagSide[2] = {{LHS->getType()->isBooleanType() ? LHS : Op->getLHS(), + Expr::EvalResult(), + {}, + false}, + {RHS->getType()->isBooleanType() ? RHS : Op->getRHS(), + Expr::EvalResult(), + {}, + false}}; for (unsigned I = 0; I < 2; I++) { const Expr *Side = DiagSide[I].Cond; Index: clang/test/Lexer/cxx1z-trigraphs.cpp =================================================================== --- clang/test/Lexer/cxx1z-trigraphs.cpp +++ clang/test/Lexer/cxx1z-trigraphs.cpp @@ -21,7 +21,7 @@ #if !ENABLED_TRIGRAPHS // expected-error@11 {{}} expected-warning@11 {{trigraph ignored}} -// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to ''?' == '#''}} +// expected-error@13 {{failed}} expected-warning@13 {{trigraph ignored}} expected-note@13 {{evaluates to '63 == 35'}} // expected-error@16 {{}} // expected-error@20 {{}} #else Index: clang/test/SemaCXX/static-assert.cpp =================================================================== --- clang/test/SemaCXX/static-assert.cpp +++ clang/test/SemaCXX/static-assert.cpp @@ -262,7 +262,15 @@ return 'c'; } static_assert(getChar() == 'a', ""); // expected-error {{failed}} \ - // expected-note {{evaluates to ''c' == 'a''}} + // expected-note {{evaluates to '99 == 97'}} + static_assert((char)9 == 'a', ""); // expected-error {{failed}} \ + // expected-note {{evaluates to '9 == 97'}} + static_assert((unsigned char)10 == 'a', ""); // expected-error {{failed}} \ + // expected-note {{evaluates to '10 == 97'}} + static_assert((char)-123 == 'a', ""); // expected-error {{failed}} \ + // expected-note {{evaluates to '-123 == 97'}} + static_assert((unsigned char)-4 == 'a', ""); // expected-error {{failed}} \ + // expected-note {{evaluates to '252 == 97'}} /// Bools are printed as bools. constexpr bool invert(bool b) {