Commit 61b204bf by Paolo Carlini Committed by Paolo Carlini

decl.c (grokdeclarator): Use declspecs->locations and declarator->id_loc in a few error messages.

/cp
2019-09-16  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (grokdeclarator): Use declspecs->locations and
	declarator->id_loc in a few error messages.
	* pt.c (finish_member_template_decl): Use DECL_SOURCE_LOCATION.
	(push_template_decl_real): Likewise.

/testsuite
2019-09-16  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/ext/int128-6.C: New.
	* c-c++-common/pr68107.c: Test location(s).
	* g++.dg/other/large-size-array.C: Likewise.
	* g++.dg/template/dtor2.C: Likewise.
	* g++.dg/template/error9.C: Likewise.
	* g++.dg/tls/diag-2.C: Likewise.
	* g++.dg/tls/diag-4.C: Likewise.
	* g++.dg/tls/diag-5.C: Likewise.
	* g++.old-deja/g++.pt/memtemp71.C: Likewise.

From-SVN: r275759
parent b3a77aa6
2019-09-16 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (grokdeclarator): Use declspecs->locations and
declarator->id_loc in a few error messages.
* pt.c (finish_member_template_decl): Use DECL_SOURCE_LOCATION.
(push_template_decl_real): Likewise.
2019-09-15 Jason Merrill <jason@redhat.com>
PR c++/30277 - int-width bit-field promotion.
......
......@@ -10948,14 +10948,15 @@ grokdeclarator (const cp_declarator *declarator,
{
if (! int_n_enabled_p[declspecs->int_n_idx])
{
error ("%<__int%d%> is not supported by this target",
int_n_data[declspecs->int_n_idx].bitsize);
error_at (declspecs->locations[ds_type_spec],
"%<__int%d%> is not supported by this target",
int_n_data[declspecs->int_n_idx].bitsize);
explicit_intN = false;
}
/* Don't pedwarn if the alternate "__intN__" form has been used instead
of "__intN". */
else if (!int_n_alt && pedantic && ! in_system_header_at (input_location))
pedwarn (input_location, OPT_Wpedantic,
pedwarn (declspecs->locations[ds_type_spec], OPT_Wpedantic,
"ISO C++ does not support %<__int%d%> for %qs",
int_n_data[declspecs->int_n_idx].bitsize, name);
}
......@@ -11330,7 +11331,10 @@ grokdeclarator (const cp_declarator *declarator,
&& storage_class != sc_static)
|| typedef_p))
{
error ("multiple storage classes in declaration of %qs", name);
location_t loc
= min_location (declspecs->locations[ds_thread],
declspecs->locations[ds_storage_class]);
error_at (loc, "multiple storage classes in declaration of %qs", name);
thread_p = false;
}
if (decl_context != NORMAL
......@@ -11489,7 +11493,9 @@ grokdeclarator (const cp_declarator *declarator,
type = create_array_type_for_decl (dname, type,
declarator->u.array.bounds,
declarator->id_loc);
if (!valid_array_size_p (input_location, type, dname))
if (!valid_array_size_p (dname
? declarator->id_loc : input_location,
type, dname))
type = error_mark_node;
if (declarator->std_attributes)
......
......@@ -298,7 +298,8 @@ finish_member_template_decl (tree decl)
return NULL_TREE;
}
else if (TREE_CODE (decl) == FIELD_DECL)
error ("data member %qD cannot be a member template", decl);
error_at (DECL_SOURCE_LOCATION (decl),
"data member %qD cannot be a member template", decl);
else if (DECL_TEMPLATE_INFO (decl))
{
if (!DECL_TEMPLATE_SPECIALIZATION (decl))
......@@ -310,7 +311,8 @@ finish_member_template_decl (tree decl)
return decl;
}
else
error ("invalid member template declaration %qD", decl);
error_at (DECL_SOURCE_LOCATION (decl),
"invalid member template declaration %qD", decl);
return error_mark_node;
}
......@@ -5515,7 +5517,8 @@ push_template_decl_real (tree decl, bool is_friend)
/* [temp.mem]
A destructor shall not be a member template. */
error ("destructor %qD declared as member template", decl);
error_at (DECL_SOURCE_LOCATION (decl),
"destructor %qD declared as member template", decl);
return error_mark_node;
}
if (IDENTIFIER_NEWDEL_OP_P (DECL_NAME (decl))
......
2019-09-16 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/ext/int128-6.C: New.
* c-c++-common/pr68107.c: Test location(s).
* g++.dg/other/large-size-array.C: Likewise.
* g++.dg/template/dtor2.C: Likewise.
* g++.dg/template/error9.C: Likewise.
* g++.dg/tls/diag-2.C: Likewise.
* g++.dg/tls/diag-4.C: Likewise.
* g++.dg/tls/diag-5.C: Likewise.
* g++.old-deja/g++.pt/memtemp71.C: Likewise.
2019-09-16 Li Jia He <helijia@linux.ibm.com>
Qi Feng <ffengqi@linux.ibm.com>
......
......@@ -3,34 +3,34 @@
#define N ((__SIZE_MAX__ / sizeof (int)) / 2 + 1)
typedef int (*T1)[N]; /* { dg-error "exceeds maximum object size" } */
typedef int (*T1)[N]; /* { dg-error "15:exceeds maximum object size" } */
typedef int (*T2)[N - 1];
typedef int (*T3)[N][N]; /* { dg-error "exceeds maximum object size" } */
typedef int (*T4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */
typedef int (**T5)[N]; /* { dg-error "exceeds maximum object size" } */
typedef int (*T3)[N][N]; /* { dg-error "15:exceeds maximum object size" } */
typedef int (*T4)[N - 1][N - 1]; /* { dg-error "15:exceeds maximum object size" } */
typedef int (**T5)[N]; /* { dg-error "16:exceeds maximum object size" } */
struct S {
int (*q1)[N]; /* { dg-error "exceeds maximum object size" } */
int (*q1)[N]; /* { dg-error "9:exceeds maximum object size" } */
int (*q2)[N - 1];
int (*q3)[N][N]; /* { dg-error "exceeds maximum object size" } */
int (*q4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */
int (**q5)[N]; /* { dg-error "exceeds maximum object size" } */
int (*q3)[N][N]; /* { dg-error "9:exceeds maximum object size" } */
int (*q4)[N - 1][N - 1]; /* { dg-error "9:exceeds maximum object size" } */
int (**q5)[N]; /* { dg-error "10:exceeds maximum object size" } */
};
void fn1 (int (*p1)[N]); /* { dg-error "exceeds maximum object size" } */
void fn1 (int (*p1)[N]); /* { dg-error "17:exceeds maximum object size" } */
void fn2 (int (*p1)[N - 1]);
void fn3 (int (*p3)[N][N]); /* { dg-error "exceeds maximum object size" } */
void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "exceeds maximum object size" } */
void fn5 (int (**p5)[N]); /* { dg-error "exceeds maximum object size" } */
void fn3 (int (*p3)[N][N]); /* { dg-error "17:exceeds maximum object size" } */
void fn4 (int (*p4)[N - 1][N - 1]); /* { dg-error "17:exceeds maximum object size" } */
void fn5 (int (**p5)[N]); /* { dg-error "18:exceeds maximum object size" } */
void
fn (void)
{
int (*n1)[N]; /* { dg-error "exceeds maximum object size" } */
int (*n1)[N]; /* { dg-error "9:exceeds maximum object size" } */
int (*n2)[N - 1];
int (*n3)[N][N]; /* { dg-error "exceeds maximum object size" } */
int (*n4)[N - 1][N - 1]; /* { dg-error "exceeds maximum object size" } */
int (**n5)[N]; /* { dg-error "exceeds maximum object size" } */
int (*n3)[N][N]; /* { dg-error "9:exceeds maximum object size" } */
int (*n4)[N - 1][N - 1]; /* { dg-error "9:exceeds maximum object size" } */
int (**n5)[N]; /* { dg-error "10:exceeds maximum object size" } */
sizeof (int (*)[N]); /* { dg-error "exceeds maximum object size" } */
sizeof (int [N]); /* { dg-error "exceeds maximum object size" } */
......
// { dg-do compile { target int128 } }
__int128 i __attribute__((unused)); // { dg-error "1:ISO C\\+\\+ does not support" }
unsigned __int128 ui __attribute__((unused)); // { dg-error "10:ISO C\\+\\+ does not support" }
......@@ -20,7 +20,7 @@ sub (int *a)
int
main (void)
{
int a[DIM][DIM]; /* { dg-error "exceeds maximum object size" } */
int a[DIM][DIM]; /* { dg-error "7:exceeds maximum object size" } */
return sub (&a[0][0]); /* { dg-error "declared" } */
}
......
struct Foo
{
template <int i>
~Foo() {} // { dg-error "" }
~Foo() {} // { dg-error "5:destructor .Foo::~Foo\\\(\\\)." }
};
int main()
......
......@@ -3,5 +3,5 @@
struct Foo
{
template <int i>
~Foo(); // { dg-error "" }
~Foo(); // { dg-error "5:destructor .Foo::~Foo\\\(\\\)." }
};
......@@ -4,14 +4,14 @@
__thread extern int g1; /* { dg-error "'__thread' before 'extern'" } */
__thread static int g2; /* { dg-error "'__thread' before 'static'" } */
__thread __thread int g3; /* { dg-error "duplicate '__thread'" } */
typedef __thread int g4; /* { dg-error "multiple storage classes" } */
typedef __thread int g4; /* { dg-error "9:multiple storage classes" } */
void foo()
{
__thread int l1; /* { dg-error "3:function-scope .l1. implicitly auto and declared '__thread'" } */
auto __thread int l2; /* { dg-error "multiple storage classes|data types" } */
auto __thread int l2; /* { dg-error "3:multiple storage classes|data types" } */
__thread extern int l3; /* { dg-error "'__thread' before 'extern'" } */
register __thread int l4; /* { dg-error "multiple storage classes" } */
register __thread int l4; /* { dg-error "3:multiple storage classes" } */
} /* { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } .-1 } */
__thread void f1 (); /* { dg-error "1:storage class .__thread. invalid for function" } */
......
/* Invalid __thread specifiers. */
/* { dg-require-effective-target tls } */
__thread typedef int g4; /* { dg-error "multiple storage classes" } */
__thread typedef int g4; /* { dg-error "1:multiple storage classes" } */
void foo()
{
__thread auto int l2; /* { dg-error "multiple storage classes|data types" } */
__thread register int l4; /* { dg-error "multiple storage classes" } */
__thread auto int l2; /* { dg-error "3:multiple storage classes|data types" } */
__thread register int l4; /* { dg-error "3:multiple storage classes" } */
} /* { dg-error "ISO C\\+\\+17 does not allow 'register' storage class specifier" "" { target c++17 } .-1 } */
......@@ -2,4 +2,4 @@
// Invalid __thread specifiers.
// { dg-require-effective-target tls }
struct A { __thread register int i; }; // { dg-error "multiple storage classes|storage class specified" }
struct A { __thread register int i; }; // { dg-error "12:multiple storage classes|storage class specified" }
......@@ -2,5 +2,5 @@
class A
{
template<class T>T epsilon; // { dg-error "" } invalid member template
template<class T>T epsilon; // { dg-error "22:data member .epsilon. cannot be a member template" }
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment