tsubst_flags_t complain = complain_flags (decltype_p);
vec<tree, va_gc> *args;
location_t close_paren_loc = UNKNOWN_LOCATION;
+ location_t combined_loc = UNKNOWN_LOCATION;
is_member_access = false;
}
}
+ /* Temporarily set input_location to the combined location
+ with call expression range, as e.g. build_out_target_exprs
+ called from convert_default_arg relies on input_location,
+ so updating it only when the call is fully built results
+ in inconsistencies between location handling in templates
+ and outside of templates. */
+ if (close_paren_loc != UNKNOWN_LOCATION)
+ combined_loc = make_location (token->location, start_loc,
+ close_paren_loc);
+ iloc_sentinel ils (combined_loc);
+
if (TREE_CODE (postfix_expression) == COMPONENT_REF)
{
tree instance = TREE_OPERAND (postfix_expression, 0);
complain);
if (close_paren_loc != UNKNOWN_LOCATION)
- {
- location_t combined_loc = make_location (token->location,
- start_loc,
- close_paren_loc);
- postfix_expression.set_location (combined_loc);
- }
+ postfix_expression.set_location (combined_loc);
/* The POSTFIX_EXPRESSION is certainly no longer an id. */
idk = CP_ID_KIND_NONE;
bar<int>(); // { dg-error "no match" }
/* { dg-begin-multiline-output "" }
bar<int>();
- ^
+ ~~~~~~~~^~
{ dg-end-multiline-output "" } */
}
#define FILE_4 "next_file_name.another_suffix"
#line 1 "foobar"
constexpr const char* f4 = this_file
- (
#line 1 FILE_4
- )
+ (
#line 1 "foobar"
+ )
;
A (0 == __builtin_strcmp (f4, FILE_4));
// of the function call.
#line 1
constexpr int n6 = this_line
- (
#line 99
- )
+ (
#line 1
+ )
;
A (n6 == 99);
const source_location *p1 = &s1;
const source_location *p2 = &s2;
static_assert (source_location::current ().line () == __LINE__);
-static_assert (source_location::current ().column () == 42);
+static_assert (source_location::current ().column () == 41);
constexpr bool
quux ()
return false;
if (line1 != line2)
return false;
- if (column != 33)
+ if (column != 32)
return false;
return true;
}
source_location a = foo ();
source_location b = source_location::current ();
source_location c = foo ();
- // ^ column 28
- // ^ column 49
+ // ^ column 27
+ // ^ column 48
const source_location *d[3] = { &a, &b, &c };
const char *file1 = __FILE__;
const char *function1 = __PRETTY_FUNCTION__;
return false;
if (d[j]->line () != line + j + 1)
return false;
- if (d[j]->column () != (j == 1 ? 49 : 28))
+ if (d[j]->column () != (j == 1 ? 48 : 27))
return false;
}
|| u.u.line () + 1 != v.line ()
|| s.a.column () != 18
|| s.b.column () != 18
- || s.c.column () != 50
+ || s.c.column () != 49
|| t.u.column () != 21
|| u.u.column () != 13
- || v.column () != 49)
+ || v.column () != 48)
return false;
return true;
}
--- /dev/null
+// PR c++/99672
+// { dg-do compile { target c++20 } }
+
+namespace std {
+ struct source_location {
+ struct __impl {
+ const char *_M_file_name;
+ const char *_M_function_name;
+ unsigned int _M_line, _M_column;
+ };
+ const __impl *__ptr;
+ constexpr source_location () : __ptr (nullptr) {}
+ static consteval source_location
+ current (const void *__p = __builtin_source_location ()) {
+ source_location __ret;
+ __ret.__ptr = static_cast <const __impl *> (__p);
+ return __ret;
+ }
+ constexpr const char *file_name () const {
+ return __ptr ? __ptr->_M_file_name : "";
+ }
+ constexpr const char *function_name () const {
+ return __ptr ? __ptr->_M_function_name : "";
+ }
+ constexpr unsigned line () const {
+ return __ptr ? __ptr->_M_line : 0;
+ }
+ constexpr unsigned column () const {
+ return __ptr ? __ptr->_M_column : 0;
+ }
+ };
+}
+
+constexpr int g(auto...) {
+return std::source_location::current().column();
+}
+
+constexpr int f() {
+return std::source_location::current().column();
+}
+
+constexpr int a = g();
+constexpr int b = f();
+static_assert (a == b);
const source_location *p2 = &s2;
static_assert (source_location::current ().line () == __LINE__);
-static_assert (source_location::current ().column () == 42);
+static_assert (source_location::current ().column () == 41);
constexpr bool
quux ()
return false;
if (line1 != line2)
return false;
- if (column != 33)
+ if (column != 32)
return false;
return true;
}
massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea ();
}
-// { dg-regexp "\n\[^\n]*adhoc-1_b.C:6:74: error: no matching function for call to 'massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea\\(\\)'\n massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea \\(\\);\n \\^$" }
+// { dg-regexp "\n\[^\n]*adhoc-1_b.C:6:73: error: no matching function for call to 'massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea\\(\\)'\n massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea \\(\\);\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\^~$" }
// { dg-regexp "\nIn module bob, imported at \[^\n]*adhoc-1_b.C:3:\n\[^\n]*adhoc-1_a.C:5:12: note: candidate: 'int massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea@bob\\(int\\)'\n export int massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea \\(int\\);\n \\^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~$" }
// { dg-regexp "\nIn module bob, imported at \[^\n]*adhoc-1_b.C:3:\n\[^\n]*adhoc-1_a.C:6:188: note: candidate: 'void massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea@bob\\(float\\)'\n\[ \t]*export void massivelongnamethatcausesadhoclocationsokeepaddingcharsyourgettheidea \\(float\\);\n\[ \t]*\\^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~?$" }
// For some reason dg-regexp inserts a blank line
you (1);
}
-// { dg-regexp "\[^\n]*macloc-1_c.C:7:8: error: too many arguments to function 'int me@agnes\\(\\)'\nIn module agnes, imported at \[^\n]*macloc-1_b.C:8,\nof module edith, imported at \[^\n]*macloc-1_c.C:3:\n\[^\n]*macloc-1_a.C:11:12: note: declared here\n\[^\n]*macloc-1_a.C:8:20: note: in definition of macro 'BOB'\n" }
+// { dg-regexp "\[^\n]*macloc-1_c.C:7:6: error: too many arguments to function 'int me@agnes\\(\\)'\nIn module agnes, imported at \[^\n]*macloc-1_b.C:8,\nof module edith, imported at \[^\n]*macloc-1_c.C:3:\n\[^\n]*macloc-1_a.C:11:12: note: declared here\n\[^\n]*macloc-1_a.C:8:20: note: in definition of macro 'BOB'\n" }
-// { dg-regexp "\[^\n]*macloc-1_c.C:8:9: error: too many arguments to function 'int you@agnes\\(\\)'\nIn module agnes, imported at \[^\n]*macloc-1_b.C:8,\nof module edith, imported at \[^\n]*macloc-1_c.C:3:\n\[^\n]*macloc-1_a.C:12:14: note: declared here\n\[^\n]*macloc-1_a.C:9:22: note: in definition of macro 'KEVIN'\n" }
+// { dg-regexp "\[^\n]*macloc-1_c.C:8:7: error: too many arguments to function 'int you@agnes\\(\\)'\nIn module agnes, imported at \[^\n]*macloc-1_b.C:8,\nof module edith, imported at \[^\n]*macloc-1_c.C:3:\n\[^\n]*macloc-1_a.C:12:14: note: declared here\n\[^\n]*macloc-1_a.C:9:22: note: in definition of macro 'KEVIN'\n" }
gru (2);
}
-// { dg-regexp "\[^\n]*macloc-1_d.C:8:8: error: too many arguments to function 'int me@agnes\\(\\)'\nIn module agnes, imported at \[^\n]*macloc-1_d.C:4:\n\[^\n]*macloc-1_a.C:11:12: note: declared here\n\[^\n]*macloc-1_a.C:8:20: note: in definition of macro 'BOB'\n" }
-// { dg-regexp "\[^\n]*macloc-1_d.C:9:9: error: too many arguments to function 'void gru@edith\\(\\)'\nIn module edith, imported at \[^\n]*macloc-1_d.C:3:\n\[^\n]*macloc-1_b.C:10:20: note: declared here\n\[^\n]*macloc-1_b.C:6:19: note: in definition of macro 'STUART'\n" }
+// { dg-regexp "\[^\n]*macloc-1_d.C:8:6: error: too many arguments to function 'int me@agnes\\(\\)'\nIn module agnes, imported at \[^\n]*macloc-1_d.C:4:\n\[^\n]*macloc-1_a.C:11:12: note: declared here\n\[^\n]*macloc-1_a.C:8:20: note: in definition of macro 'BOB'\n" }
+// { dg-regexp "\[^\n]*macloc-1_d.C:9:7: error: too many arguments to function 'void gru@edith\\(\\)'\nIn module edith, imported at \[^\n]*macloc-1_d.C:3:\n\[^\n]*macloc-1_b.C:10:20: note: declared here\n\[^\n]*macloc-1_b.C:6:19: note: in definition of macro 'STUART'\n" }
((base *)1)->priv (); // { dg-error " is private " }
/* { dg-begin-multiline-output "" }
((base *)1)->priv ();
- ^
+ ~~~~~~~~~~~~~~~~~~^~
{ dg-end-multiline-output "" }
{ dg-begin-multiline-output "" }
int priv ();
std::string_view main_sl_fn_name(main_sl.function_name());
std::string_view main_sl_fi_name(main_sl.file_name());
VERIFY(main_sl.line() == main_sl_line);
- // closing paren of call
- VERIFY(main_sl.column() == 64);
+ // opening paren of call
+ VERIFY(main_sl.column() == 63);
VERIFY(main_sl_fn_name.ends_with("main()"sv));
VERIFY(main_sl_fi_name.ends_with("1.cc"sv));
std::string_view f_arg_sl_fn_name(f_arg_sl.function_name());
std::string_view f_arg_sl_fi_name(f_arg_sl.file_name());
VERIFY(f_arg_sl.line() == f_arg_sl_line);
- // closing paren of call
- VERIFY(f_arg_sl.column() == 64);
+ // opening paren of call
+ VERIFY(f_arg_sl.column() == 63);
VERIFY(f_arg_sl_fn_name.ends_with("main()"sv));
VERIFY(f_arg_sl_fi_name.ends_with("1.cc"sv));
std::string_view g_sl_fn_name(g_sl.function_name());
std::string_view g_sl_fi_name(g_sl.file_name());
VERIFY(g_sl.line() == g_sl_line);
- VERIFY(g_sl.column() == 58); // closing paren of call
+ VERIFY(g_sl.column() == 57); // opening paren of call
VERIFY(g_sl_fn_name.ends_with("g()"sv));
VERIFY(g_sl_fi_name.ends_with("1.cc"sv));
std::string_view h_sl_fn_name(h_sl.function_name());
std::string_view h_sl_fi_name(h_sl.file_name());
VERIFY(h_sl.line() == 23);
- VERIFY(h_sl.column() == 58); // closing paren of call
+ VERIFY(h_sl.column() == 57); // opening paren of call
VERIFY(h_sl_fn_name.ends_with("h()"sv));
VERIFY(h_sl_fi_name.ends_with("srcloc.h"sv));
std::string_view member_main_sl_fn_name(member_main_sl.member.function_name());
std::string_view member_main_sl_fi_name(member_main_sl.member.file_name());
VERIFY(member_main_sl.member.line() == main_sl_line);
- VERIFY(member_main_sl.member.column() == 64);
+ VERIFY(member_main_sl.member.column() == 63);
VERIFY(member_main_sl_fn_name.ends_with("main()"sv));
VERIFY(member_main_sl_fi_name.ends_with("1.cc"sv));
std::string_view f_sl_fi_name(f_sl.file_name());
std::string_view f_sl_fn_name(f_sl.function_name());
VERIFY(f_sl.line() == f_sl_line);
- // closing paren of call
- VERIFY(f_sl.column() == 33);
+ // opening paren of call
+ VERIFY(f_sl.column() == 32);
VERIFY(f_sl_fn_name.ends_with("main()"sv));
VERIFY(f_sl_fi_name.ends_with("1.cc"sv));
using namespace std::string_view_literals;
static_assert (std::source_location::current ().line () == __LINE__);
- static_assert (std::source_location::current ().column () == 49);
+ static_assert (std::source_location::current ().column () == 48);
constexpr std::string_view main_sl_fn_name(main_sl.function_name());
constexpr std::string_view main_sl_fi_name(main_sl.file_name());
static_assert(main_sl.line() == main_sl_line);
- // closing paren of call
- static_assert(main_sl.column() == 74);
+ // opening paren of call
+ static_assert(main_sl.column() == 73);
static_assert(main_sl_fn_name.ends_with("main()"sv));
static_assert(main_sl_fi_name.ends_with("consteval.cc"sv));
constexpr std::string_view f_arg_sl_fn_name(f_arg_sl.function_name());
constexpr std::string_view f_arg_sl_fi_name(f_arg_sl.file_name());
static_assert(f_arg_sl.line() == f_arg_sl_line);
- // closing paren of call
- static_assert(f_arg_sl.column() == 74);
+ // opening paren of call
+ static_assert(f_arg_sl.column() == 73);
static_assert(f_arg_sl_fn_name.ends_with("main()"sv));
static_assert(f_arg_sl_fi_name.ends_with("consteval.cc"sv));
constexpr std::string_view g_sl_fn_name(g_sl.function_name());
constexpr std::string_view g_sl_fi_name(g_sl.file_name());
static_assert(g_sl.line() == g_sl_line);
- static_assert(g_sl.column() == 58); // closing paren of call
+ static_assert(g_sl.column() == 57); // opening paren of call
static_assert(g_sl_fn_name.ends_with("g()"sv));
static_assert(g_sl_fi_name.ends_with("consteval.cc"sv));
constexpr std::string_view h_sl_fn_name(h_sl.function_name());
constexpr std::string_view h_sl_fi_name(h_sl.file_name());
static_assert(h_sl.line() == 23);
- static_assert(h_sl.column() == 58); // closing paren of call
+ static_assert(h_sl.column() == 57); // opening paren of call
static_assert(h_sl_fn_name.ends_with("h()"sv));
static_assert(h_sl_fi_name.ends_with("srcloc.h"sv));
constexpr std::string_view member_main_sl_fn_name(member_main_sl.member.function_name());
constexpr std::string_view member_main_sl_fi_name(member_main_sl.member.file_name());
static_assert(member_main_sl.member.line() == main_sl_line);
- static_assert(member_main_sl.member.column() == 74);
+ static_assert(member_main_sl.member.column() == 73);
static_assert(member_main_sl_fn_name.ends_with("main()"sv));
static_assert(member_main_sl_fi_name.ends_with("consteval.cc"sv));
constexpr std::string_view f_sl_fi_name(f_sl.file_name());
constexpr std::string_view f_sl_fn_name(f_sl.function_name());
static_assert(f_sl.line() == f_sl_line);
- // closing paren of call
- static_assert(f_sl.column() == 43);
+ // opening paren of call
+ static_assert(f_sl.column() == 42);
static_assert(f_sl_fn_name.ends_with("main()"sv));
static_assert(f_sl_fi_name.ends_with("consteval.cc"sv));