Hi,
today I noticed quite a few additional places where we can exploit
declarator->id_loc, the below are the first bits. Tested x86_64-linux.
Thanks, Paolo.
//
/cp
2018-10-30 Paolo Carlini
* decl.c (grokdeclarator): Use declarator->id_loc in diagnostic
about flexible array members.
/testsuite
2018-10-30 Paolo Carlini
* g++.dg/cpp1z/has-unique-obj-representations1.C: Test location too.
* g++.dg/ext/flexarray-mangle-2.C: Likewise.
* g++.dg/ext/flexarray-mangle.C: Likewise.
* g++.dg/ext/flexarray-subst.C: Likewise.
* g++.dg/ext/flexary10.C: Likewise.
* g++.dg/ext/flexary11.C: Likewise.
* g++.dg/ext/flexary14.C: Likewise.
* g++.dg/ext/flexary16.C: Likewise.
* g++.dg/ext/flexary26.C: Likewise.
* g++.dg/ext/flexary27.C: Likewise.
* g++.dg/ext/flexary7.C: Likewise.
* g++.dg/ext/pr71290.C: Likewise.Index: cp/decl.c
===
--- cp/decl.c (revision 265616)
+++ cp/decl.c (working copy)
@@ -12210,7 +12223,7 @@ grokdeclarator (const cp_declarator *declarator,
/* Do not warn on flexible array members in system
headers because glibc uses them. */;
else if (name)
- pedwarn (input_location, OPT_Wpedantic,
+ pedwarn (declarator->id_loc, OPT_Wpedantic,
"ISO C++ forbids flexible array member %qs", name);
else
pedwarn (input_location, OPT_Wpedantic,
Index: testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C
===
--- testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C(revision
265616)
+++ testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C(working copy)
@@ -9,7 +9,7 @@ struct V { int i : INTB * 3 / 4; int j : INTB / 4
struct W {};
struct X : public W { int i; void bar (); };
struct Y {
- char a[3]; char b[]; // { dg-warning "forbids flexible array member" }
+ char a[3]; char b[]; // { dg-warning "19:ISO C\\+\\+ forbids flexible
array member" }
};
struct Z { int a; float b; };
struct A { int i : INTB * 2; int j; }; // { dg-warning
"exceeds its type" }
Index: testsuite/g++.dg/ext/flexarray-mangle-2.C
===
--- testsuite/g++.dg/ext/flexarray-mangle-2.C (revision 265616)
+++ testsuite/g++.dg/ext/flexarray-mangle-2.C (working copy)
@@ -4,7 +4,7 @@
struct A {
int n;
- char a[]; // { dg-warning "forbids flexible array member" }
+ char a[]; // { dg-warning "8:ISO C\\+\\+ forbids flexible array member" }
};
// Declare but do not define function templates.
Index: testsuite/g++.dg/ext/flexarray-mangle.C
===
--- testsuite/g++.dg/ext/flexarray-mangle.C (revision 265616)
+++ testsuite/g++.dg/ext/flexarray-mangle.C (working copy)
@@ -4,7 +4,7 @@
struct A {
int n;
- char a[]; // { dg-warning "forbids flexible array member" }
+ char a[]; // { dg-warning "8:ISO C\\+\\+ forbids flexible array member" }
};
// Declare but do not define function templates.
Index: testsuite/g++.dg/ext/flexarray-subst.C
===
--- testsuite/g++.dg/ext/flexarray-subst.C (revision 265616)
+++ testsuite/g++.dg/ext/flexarray-subst.C (working copy)
@@ -5,7 +5,7 @@
struct A {
int n;
- char a[]; // { dg-warning "forbids flexible array member" }
+ char a[]; // { dg-warning "8:ISO C\\+\\+ forbids flexible array member" }
};
template
Index: testsuite/g++.dg/ext/flexary10.C
===
--- testsuite/g++.dg/ext/flexary10.C(revision 265616)
+++ testsuite/g++.dg/ext/flexary10.C(working copy)
@@ -4,7 +4,7 @@
struct A {
int n;
- int a[]; // { dg-warning "forbids flexible array member" }
+ int a[]; // { dg-warning "7:ISO C\\+\\+ forbids flexible array member" }
};
struct A foo (void)
Index: testsuite/g++.dg/ext/flexary11.C
===
--- testsuite/g++.dg/ext/flexary11.C(revision 265616)
+++ testsuite/g++.dg/ext/flexary11.C(working copy)
@@ -4,7 +4,7 @@
struct A {
int n;
- char a[]; // { dg-error "forbids flexible array member" }
+ char a[]; // { dg-error "8:ISO C\\+\\+ forbids flexible array member" }
};
void f ()
Index: testsuite/g++.dg/ext/flexary14.C
===
--- testsuite/g++.dg/ext/flexary14.C(revision 265616)
+++ testsuite/g++.dg/ext/flexary14.C(working copy)
@@ -10,7 +10,7 @@ struct A { typedef int X; };
template int foo (T&, typename A::X = 0) { return 0; }
struct B {
- int n, a[]; // { dg-error "forbids flexible array