aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2018-10-29 22:57:39 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2018-10-29 22:57:39 +0000
commitebdb73c0b0950509eab6a5fa7f0f5b360c6e5cca (patch)
treebf48e3d4f8d3136e880e1cf660a7d68dbe911aac /gcc
parent64ac3c33ba88dd3b248ff7c07709a2d28e9b1dfe (diff)
downloadgcc-ebdb73c0b0950509eab6a5fa7f0f5b360c6e5cca.zip
gcc-ebdb73c0b0950509eab6a5fa7f0f5b360c6e5cca.tar.gz
gcc-ebdb73c0b0950509eab6a5fa7f0f5b360c6e5cca.tar.bz2
decl.c (create_array_type_for_decl): Add location_t parameter and use it.
/cp 2018-10-29 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (create_array_type_for_decl): Add location_t parameter and use it. (grokdeclarator): Adjust call. /testsuite 2018-10-29 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/auto24.C: Test location too. * g++.dg/cpp0x/auto3.C: Likewise. * g++.dg/cpp0x/auto42.C: Likewise. * g++.dg/cpp0x/initlist57.C: Likewise. * g++.dg/cpp0x/initlist75.C: Likewise. * g++.dg/cpp0x/initlist80.C: Likewise. * g++.dg/cpp0x/lambda/lambda-ice13.C: Likewise. * g++.old-deja/g++.brendan/array-refs.C: Likewise. * g++.old-deja/g++.bugs/900322_01.C: Likewise. * g++.old-deja/g++.bugs/900519_07.C: Likewise. * g++.old-deja/g++.other/typeck1.C: Likewise. From-SVN: r265608
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c26
-rw-r--r--gcc/testsuite/ChangeLog14
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto24.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto3.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/auto42.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist57.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist75.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist80.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C3
-rw-r--r--gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C19
-rw-r--r--gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C6
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/typeck1.C4
14 files changed, 58 insertions, 34 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6b9574a..b1e7f23 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2018-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (create_array_type_for_decl): Add location_t parameter
+ and use it.
+ (grokdeclarator): Adjust call.
+
2018-10-29 Marek Polacek <polacek@redhat.com>
PR c++/87594 - constexpr rejects-valid with range-based for.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5ebfaaf..00e75f0 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -88,7 +88,7 @@ static void finish_constructor_body (void);
static void begin_destructor_body (void);
static void finish_destructor_body (void);
static void record_key_method_defined (tree);
-static tree create_array_type_for_decl (tree, tree, tree);
+static tree create_array_type_for_decl (tree, tree, tree, location_t);
static tree get_atexit_node (void);
static tree get_dso_handle_node (void);
static tree start_cleanup_fn (void);
@@ -9835,7 +9835,7 @@ get_scope_of_declarator (const cp_declarator *declarator)
with this type. */
static tree
-create_array_type_for_decl (tree name, tree type, tree size)
+create_array_type_for_decl (tree name, tree type, tree size, location_t loc)
{
tree itype = NULL_TREE;
@@ -9848,9 +9848,9 @@ create_array_type_for_decl (tree name, tree type, tree size)
if (type_uses_auto (type))
{
if (name)
- error ("%qD declared as array of %qT", name, type);
+ error_at (loc, "%qD declared as array of %qT", name, type);
else
- error ("creating array of %qT", type);
+ error ("creating array of %qT", type);
return error_mark_node;
}
@@ -9860,28 +9860,29 @@ create_array_type_for_decl (tree name, tree type, tree size)
{
case VOID_TYPE:
if (name)
- error ("declaration of %qD as array of void", name);
+ error_at (loc, "declaration of %qD as array of void", name);
else
error ("creating array of void");
return error_mark_node;
case FUNCTION_TYPE:
if (name)
- error ("declaration of %qD as array of functions", name);
+ error_at (loc, "declaration of %qD as array of functions", name);
else
error ("creating array of functions");
return error_mark_node;
case REFERENCE_TYPE:
if (name)
- error ("declaration of %qD as array of references", name);
+ error_at (loc, "declaration of %qD as array of references", name);
else
error ("creating array of references");
return error_mark_node;
case METHOD_TYPE:
if (name)
- error ("declaration of %qD as array of function members", name);
+ error_at (loc, "declaration of %qD as array of function members",
+ name);
else
error ("creating array of function members");
return error_mark_node;
@@ -9897,9 +9898,9 @@ create_array_type_for_decl (tree name, tree type, tree size)
if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type))
{
if (name)
- error ("declaration of %qD as multidimensional array must "
- "have bounds for all dimensions except the first",
- name);
+ error_at (loc, "declaration of %qD as multidimensional array must "
+ "have bounds for all dimensions except the first",
+ name);
else
error ("multidimensional array must have bounds for all "
"dimensions except the first");
@@ -11164,7 +11165,8 @@ grokdeclarator (const cp_declarator *declarator,
{
case cdk_array:
type = create_array_type_for_decl (dname, type,
- declarator->u.array.bounds);
+ declarator->u.array.bounds,
+ declarator->id_loc);
if (!valid_array_size_p (input_location, type, dname))
type = error_mark_node;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c8e9c57..85e910f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,17 @@
+2018-10-29 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/cpp0x/auto24.C: Test location too.
+ * g++.dg/cpp0x/auto3.C: Likewise.
+ * g++.dg/cpp0x/auto42.C: Likewise.
+ * g++.dg/cpp0x/initlist57.C: Likewise.
+ * g++.dg/cpp0x/initlist75.C: Likewise.
+ * g++.dg/cpp0x/initlist80.C: Likewise.
+ * g++.dg/cpp0x/lambda/lambda-ice13.C: Likewise.
+ * g++.old-deja/g++.brendan/array-refs.C: Likewise.
+ * g++.old-deja/g++.bugs/900322_01.C: Likewise.
+ * g++.old-deja/g++.bugs/900519_07.C: Likewise.
+ * g++.old-deja/g++.other/typeck1.C: Likewise.
+
2018-10-29 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/87469
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto24.C b/gcc/testsuite/g++.dg/cpp0x/auto24.C
index d370cc6..193f92e 100644
--- a/gcc/testsuite/g++.dg/cpp0x/auto24.C
+++ b/gcc/testsuite/g++.dg/cpp0x/auto24.C
@@ -2,4 +2,4 @@
// { dg-do compile { target c++11 } }
int v[1];
-auto (*p)[1] = &v; // { dg-error "array of .auto" }
+auto (*p)[1] = &v; // { dg-error "8:.p. declared as array of .auto" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto3.C b/gcc/testsuite/g++.dg/cpp0x/auto3.C
index ed7084b..709898d 100644
--- a/gcc/testsuite/g++.dg/cpp0x/auto3.C
+++ b/gcc/testsuite/g++.dg/cpp0x/auto3.C
@@ -10,7 +10,7 @@ auto x; // { dg-error "auto" }
auto i = 42, j = 42.0; // { dg-error "auto" }
// New CWG issue
-auto a[2] = { 1, 2 }; // { dg-error "auto|initializer_list" }
+auto a[2] = { 1, 2 }; // { dg-error "6:.a. declared as array of .auto" }
template<class T>
struct A { };
diff --git a/gcc/testsuite/g++.dg/cpp0x/auto42.C b/gcc/testsuite/g++.dg/cpp0x/auto42.C
index fea4c28..8d15fc9 100644
--- a/gcc/testsuite/g++.dg/cpp0x/auto42.C
+++ b/gcc/testsuite/g++.dg/cpp0x/auto42.C
@@ -5,5 +5,5 @@
void foo(int i)
{
- auto x[1] = { 0 }; // { dg-error "array of .auto" }
+ auto x[1] = { 0 }; // { dg-error "8:.x. declared as array of .auto" }
}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist57.C b/gcc/testsuite/g++.dg/cpp0x/initlist57.C
index 5c59f40..6f662ef 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist57.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist57.C
@@ -1,7 +1,7 @@
// PR c++/50054
// { dg-do compile { target c++11 } }
-void g( const int& (a)[1] ) {} // { dg-error "array of references" }
+void g( const int& (a)[1] ) {} // { dg-error "21:declaration of .a. as array of references" }
int main () {
g( { 1, 2 } ); // { dg-error "initializer list" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist75.C b/gcc/testsuite/g++.dg/cpp0x/initlist75.C
index f185401..9a45087 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist75.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist75.C
@@ -3,4 +3,4 @@
#include <initializer_list>
-auto foo[] = {}; // { dg-error "auto|unable to deduce" }
+auto foo[] = {}; // { dg-error "6:.foo. declared as array of .auto" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist80.C b/gcc/testsuite/g++.dg/cpp0x/initlist80.C
index 7947f1f..15723be 100644
--- a/gcc/testsuite/g++.dg/cpp0x/initlist80.C
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist80.C
@@ -3,4 +3,4 @@
#include <initializer_list>
-auto x[2] = {}; // { dg-error "" }
+auto x[2] = {}; // { dg-error "6:.x. declared as array of .auto" }
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C
index 4c611ad..cbac7e8 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice13.C
@@ -10,5 +10,6 @@ void f()
void g()
{
typedef void (X) ();
- X x[] = { [x](){} }; // { dg-error "array of functions|not declared" }
+ X x[] = { [x](){} }; // { dg-error "5:declaration of .x. as array of functions" }
+ // { dg-error "not declared" "" { target *-*-* } .-1 }
}
diff --git a/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C b/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C
index b834867..e50e9eb 100644
--- a/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C
+++ b/gcc/testsuite/g++.old-deja/g++.brendan/array-refs.C
@@ -3,4 +3,4 @@
int a, b;
// declaring an array of references should be illegal
-int & v[ 2] = { a, b};// { dg-error "" } .*
+int & v[ 2] = { a, b}; // { dg-error "7:declaration of .v. as array of references" }
diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C b/gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C
index bd3296a..e0c4a29 100644
--- a/gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C
+++ b/gcc/testsuite/g++.old-deja/g++.bugs/900322_01.C
@@ -33,24 +33,25 @@
// keywords: incomplete types, arrays, element types
-extern int extern_two_d [] []; // { dg-error "" } invalid declaration
-int tenative_two_d [] []; // { dg-error "" } caught by g++
-static int static_two_d [] []; // { dg-error "" } caught by g++
+extern int extern_two_d [] []; // { dg-error "12:declaration of .extern_two_d. as multidimensional" } invalid declaration
+int tenative_two_d [] []; // { dg-error "5:declaration of .tenative_two_d. as multidimensional" } caught by g++
+static int static_two_d [] []; // { dg-error "12:declaration of .static_two_d. as multidimensional" } caught by g++
-int (*pointer_to_two_d)[][]; // { dg-error "" } invalid declaration
+int (*pointer_to_two_d)[][]; // { dg-error "7:declaration of .pointer_to_two_d. as multidimensional" } invalid declaration
-void function_0 (int arg [] []) { // { dg-error "" } invalid declaration
+void function_0 (int arg [] []) { // { dg-error "22:declaration of .arg. as multidimensional" } invalid declaration
}
typedef int int_one_d_type [];
-typedef int_one_d_type int_two_d_type[];// { dg-error "" } invalid declaration
+typedef int_one_d_type int_two_d_type[];// { dg-error "24:declaration of .int_two_d_type. as multidimensional" } invalid declaration
struct s;
extern struct s extern_s_array [10]; // OK
-struct s tenative_s_array [10]; // { dg-error "" } object with incomplete type
-static struct s static_s_array [10]; // { dg-error "" } object with incomplete type
-
+struct s tenative_s_array [10]; // { dg-error "10:elements of array .s tenative_s_array \\\[10\\\]. have incomplete type" } object with incomplete type
+// { dg-error "10:storage size" "" { target *-*-* } .-1 }
+static struct s static_s_array [10]; // { dg-error "17:elements of array .s static_s_array \\\[10\\\]. have incomplete type" } object with incomplete type
+// { dg-error "17:storage size" "" { target *-*-* } .-1 }
struct s (*pointer_to_s_array) []; // OK
void function_1 (struct s arg []) { // OK
diff --git a/gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C b/gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C
index 650147e..10e7abd 100644
--- a/gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C
+++ b/gcc/testsuite/g++.old-deja/g++.bugs/900519_07.C
@@ -11,7 +11,7 @@ int i;
int j;
typedef int& int_ref;
-typedef int_ref int_ref_array_type[2]; // { dg-error "" } missed
+typedef int_ref int_ref_array_type[2]; // { dg-error "17:declaration of .int_ref_array_type. as array of references" } missed
-int& int_ref_array_obj0[2] = { i, j }; // { dg-error "" } missed
-int_ref int_ref_array_obj1[2] = { i, j }; // { dg-error "" } missed
+int& int_ref_array_obj0[2] = { i, j }; // { dg-error "6:declaration of .int_ref_array_obj0. as array of references" } missed
+int_ref int_ref_array_obj1[2] = { i, j }; // { dg-error "9:declaration of .int_ref_array_obj1. as array of references" } missed
diff --git a/gcc/testsuite/g++.old-deja/g++.other/typeck1.C b/gcc/testsuite/g++.old-deja/g++.other/typeck1.C
index 1dce273..d520667 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/typeck1.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/typeck1.C
@@ -1,7 +1,7 @@
// { dg-do assemble }
-extern int a[][]; // { dg-error "" } invalid multidimensional array
-extern int b[7][]; // { dg-error "" } invalid multidimensional array
+extern int a[][]; // { dg-error "12:declaration of .a. as multidimensional array" } invalid multidimensional array
+extern int b[7][]; // { dg-error "12:declaration of .b. as multidimensional array" } invalid multidimensional array
extern int c[][7]; // OK
extern int (*i)[]; // { dg-message "" } previous declaration