Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -95,6 +95,8 @@ Improvements to Clang's diagnostics ----------------------------------- +- Clang constexpr evaluator now prints template arguments when displaying + template-specialization function calls. Bug Fixes in This Version ------------------------- Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -1950,7 +1950,8 @@ cast(Callee)->isInstance(); if (!IsMemberCall) - Out << *Callee << '('; + Callee->getNameForDiagnostic(Out, Info.Ctx.getPrintingPolicy(), + /*Qualified=*/false); if (This && IsMemberCall) { if (const auto *MCE = dyn_cast_if_present(CallExpr)) { @@ -1975,10 +1976,13 @@ Info.Ctx.getLValueReferenceType(This->Designator.MostDerivedType)); Out << "."; } - Out << *Callee << '('; + Callee->getNameForDiagnostic(Out, Info.Ctx.getPrintingPolicy(), + /*Qualified=*/false); IsMemberCall = false; } + Out << '('; + for (FunctionDecl::param_const_iterator I = Callee->param_begin(), E = Callee->param_end(); I != E; ++I, ++ArgIndex) { if (ArgIndex > (unsigned)IsMemberCall) Index: clang/test/AST/Interp/literals.cpp =================================================================== --- clang/test/AST/Interp/literals.cpp +++ clang/test/AST/Interp/literals.cpp @@ -502,22 +502,22 @@ return 1; } static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \ - // ref-note {{in call to 'uninit()'}} \ + // ref-note {{in call to 'uninit()'}} \ // expected-error {{not an integral constant expression}} \ // expected-note {{in call to 'uninit()'}} static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \ - // ref-note {{in call to 'uninit()'}} \ + // ref-note {{in call to 'uninit()'}} \ // expected-error {{not an integral constant expression}} \ // expected-note {{in call to 'uninit()'}} static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \ - // ref-note {{in call to 'uninit()'}} \ + // ref-note {{in call to 'uninit()'}} \ // expected-error {{not an integral constant expression}} \ // expected-note {{in call to 'uninit()'}} static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \ - // ref-note {{in call to 'uninit()'}} \ + // ref-note {{in call to 'uninit()'}} \ // expected-error {{not an integral constant expression}} \ // expected-note {{in call to 'uninit()'}} Index: clang/test/SemaCXX/builtin-align-cxx.cpp =================================================================== --- clang/test/SemaCXX/builtin-align-cxx.cpp +++ clang/test/SemaCXX/builtin-align-cxx.cpp @@ -137,26 +137,26 @@ constexpr long const_value(long l) { return l; } // Check some invalid values during constant-evaluation static_assert(wrap_align_down(1, const_value(-1)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_align_down(1, -1)'}} +// expected-note@-1{{in call to 'wrap_align_down(1, -1)'}} static_assert(wrap_align_up(1, const_value(-2)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_align_up(1, -2)'}} +// expected-note@-1{{in call to 'wrap_align_up(1, -2)'}} static_assert(wrap_is_aligned(1, const_value(-3)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_is_aligned(1, -3)'}} +// expected-note@-1{{in call to 'wrap_is_aligned(1, -3)'}} static_assert(wrap_align_down(1, const_value(17)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_align_down(1, 17)'}} +// expected-note@-1{{in call to 'wrap_align_down(1, 17)'}} static_assert(wrap_align_up(1, const_value(18)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_align_up(1, 18)'}} +// expected-note@-1{{in call to 'wrap_align_up(1, 18)'}} static_assert(wrap_is_aligned(1, const_value(19)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_is_aligned(1, 19)'}} +// expected-note@-1{{in call to 'wrap_is_aligned(1, 19)'}} // Check invalid values for smaller types: static_assert(wrap_align_down(static_cast(1), const_value(1 << 20)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_align_down(1, 1048576)'}} +// expected-note@-1{{in call to 'wrap_align_down(1, 1048576)'}} // Check invalid boolean type static_assert(wrap_align_up(static_cast(1), const_value(1ull << 33)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_align_up(1, 8589934592)'}} +// expected-note@-1{{in call to 'wrap_align_up(1, 8589934592)'}} static_assert(wrap_is_aligned(static_cast(1), const_value(1 << 22)), ""); // expected-error{{not an integral constant expression}} -// expected-note@-1{{in call to 'wrap_is_aligned(1, 4194304)'}} +// expected-note@-1{{in call to 'wrap_is_aligned(1, 4194304)'}} // Check invalid boolean type static_assert(wrap_align_up(static_cast(1), const_value(1 << 21)), ""); // expected-error{{not an integral constant expression}} Index: clang/test/SemaCXX/constant-expression-cxx11.cpp =================================================================== --- clang/test/SemaCXX/constant-expression-cxx11.cpp +++ clang/test/SemaCXX/constant-expression-cxx11.cpp @@ -1781,7 +1781,7 @@ static_assert(get(arr, 1) == 1, ""); static_assert(get(arr, 4) == 4, ""); static_assert(get(arr, 0) == 4, ""); // expected-error{{not an integral constant expression}} \ - // expected-note{{in call to 'get(arr, 0)'}} + // expected-note{{in call to 'get(arr, 0)'}} } namespace std { struct type_info; } Index: clang/test/SemaCXX/constant-expression-cxx14.cpp =================================================================== --- clang/test/SemaCXX/constant-expression-cxx14.cpp +++ clang/test/SemaCXX/constant-expression-cxx14.cpp @@ -1039,7 +1039,7 @@ void foo() __attribute__((enable_if(sum(Cs) == 'a' + 'b', ""))); void run() { foo(); } -static_assert(sum(Cs) == 'a' + 'b', ""); // expected-error{{not an integral constant expression}} expected-note{{in call to 'sum(Cs)'}} +static_assert(sum(Cs) == 'a' + 'b', ""); // expected-error{{not an integral constant expression}} expected-note{{in call to 'sum<2>(Cs)'}} constexpr int S = sum(Cs); // expected-error{{must be initialized by a constant expression}} expected-note{{in call}} } Index: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp =================================================================== --- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp +++ clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp @@ -117,11 +117,11 @@ constexpr pad pir{4, 4}; // expected-error@+2 {{constexpr variable 'piw' must be initialized by a constant expression}} - // expected-note@+1 {{in call to 'bit_cast(pir)'}} + // expected-note@+1 {{in call to 'bit_cast(pir)'}} constexpr int piw = bit_cast(pir).x; // expected-error@+2 {{constexpr variable 'bad' must be initialized by a constant expression}} - // expected-note@+1 {{in call to 'bit_cast(pir)'}} + // expected-note@+1 {{in call to 'bit_cast(pir)'}} constexpr no_pad bad = bit_cast(pir); constexpr pad fine = bit_cast(no_pad{1, 2, 3, 4, 5}); Index: clang/test/SemaCXX/constexpr-frame-describe.cpp =================================================================== --- clang/test/SemaCXX/constexpr-frame-describe.cpp +++ clang/test/SemaCXX/constexpr-frame-describe.cpp @@ -58,3 +58,24 @@ constexpr D d{}; static_assert(d.c->b.a->foo() == 1); // expected-error {{constant expression}} \ expected-note {{in call to 'd.c->b.a->foo()'}} + +template +struct Bar { + template + constexpr int fail1() const { return 1 / 0; } // expected-warning {{division by zero}} \ + // expected-note {{division by zero}} + template + constexpr int fail2() const { return 1 / 0; } // expected-warning {{division by zero}} \ + // expected-note {{division by zero}} + template + constexpr int fail3(Args... args) const { return 1 / 0; } // expected-warning {{division by zero}} \ + // expected-note {{division by zero}} +}; + +constexpr Bar bar; +static_assert(bar.fail1()); // expected-error {{constant expression}} \ + // expected-note {{in call to 'bar.fail1()'}} +static_assert(bar.fail2()); // expected-error {{constant expression}} \ + // expected-note {{in call to 'bar.fail2()'}} +static_assert(bar.fail3(3, 4UL, bar, &bar)); // expected-error {{constant expression}} \ + // expected-note {{in call to 'bar.fail3, const Bar *>(3, 4, {}, &bar)'}} Index: clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp =================================================================== --- clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp +++ clang/test/SemaCXX/cxx2a-constexpr-dynalloc-limits.cpp @@ -88,11 +88,11 @@ void ohno() { int bar[stack_array<1024>()]; int foo[stack_array<1025>()]; // expected-warning {{variable length arrays are a C99 feature}} \ - // expected-note {{in call to 'stack_array()'}} + // expected-note {{in call to 'stack_array<1025>()'}} constexpr int foo[stack_array<1025>()]; // expected-warning {{variable length arrays are a C99 feature}} \ // expected-error {{constexpr variable cannot have non-literal type 'const int[stack_array<1025>()]'}} \ - // expected-note {{in call to 'stack_array()'}} + // expected-note {{in call to 'stack_array<1025>()'}} } } Index: clang/test/SemaCXX/cxx2b-consteval-propagate.cpp =================================================================== --- clang/test/SemaCXX/cxx2b-consteval-propagate.cpp +++ clang/test/SemaCXX/cxx2b-consteval-propagate.cpp @@ -45,7 +45,7 @@ } int i = hh(); // expected-error {{call to immediate function 'examples::hh' is not a constant expression}} \ - // expected-note {{in call to 'hh()'}} + // expected-note {{in call to 'hh()'}} struct A { int x; @@ -180,7 +180,7 @@ void test_runtime() { (void)immediate(0); // expected-error {{call to immediate function 'Aggregate::immediate' is not a constant expression}} \ - // expected-note {{in call to 'immediate(0)'}} + // expected-note {{in call to 'immediate(0)'}} } consteval int f(int i) { return i;