diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index ef96e140f24..767478cf5fd 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -3774,6 +3774,8 @@ print_instantiation_partial_context_line (diagnostic_context *context, ? _("recursively required from here\n") : _("required from here\n")); } + gcc_rich_location rich_loc (loc); + diagnostic_show_locus (context, &rich_loc, DK_NOTE); } /* Same as print_instantiation_full_context but less verbose. */ diff --git a/gcc/testsuite/g++.dg/diagnostic/static_assert3.C b/gcc/testsuite/g++.dg/diagnostic/static_assert3.C index 5d363884508..4ec53f17120 100644 --- a/gcc/testsuite/g++.dg/diagnostic/static_assert3.C +++ b/gcc/testsuite/g++.dg/diagnostic/static_assert3.C @@ -5,6 +5,11 @@ template struct is_same { static constexpr bool value = false; }; template struct is_same { static constexpr bool value = true; }; +/* { dg-begin-multiline-output "" } + f(0, 1.3); + ~^~~~~~~~ + { dg-end-multiline-output "" } */ + template void f(T, U) { @@ -32,5 +37,5 @@ void f(T, U) void g() { - f(0, 1.3); + f(0, 1.3); // { dg-message " required from here" } } diff --git a/gcc/testsuite/g++.dg/template/error60.C b/gcc/testsuite/g++.dg/template/error60.C new file mode 100644 index 00000000000..8c2139b207c --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error60.C @@ -0,0 +1,37 @@ +// { dg-options "-fdiagnostics-show-caret" } + +template +struct my_pointer +{ + my_pointer (Foo *ptr) // { dg-message " initializing argument 1" } + : m_ptr (ptr) + {} + + Foo *m_ptr; +}; + +template +void test (Foo val) +{ + my_pointer ptr (val); // { dg-error "invalid conversion from 'int' to 'int\\*'" } +} + +void usage () +{ + test (42); // { dg-message " required from here" } + /* { dg-begin-multiline-output "" } + test (42); + ~~~~~~~~~~^~~~ + { dg-end-multiline-output "" } */ +} + + /* { dg-begin-multiline-output "" } + my_pointer (Foo *ptr) + ~~~~~^~~ + { dg-end-multiline-output "" } */ + /* { dg-begin-multiline-output "" } + my_pointer ptr (val); + ^~~ + | + int + { dg-end-multiline-output "" } */