From 190facef83142f0b226b72d93abca4ee21347bfa Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Tue, 30 Oct 2018 18:29:49 +0000 Subject: [PATCH] decl.c (grokdeclarator): Use declarator->id_loc in diagnostic about flexible array members. /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. From-SVN: r265636 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/decl.c | 2 +- gcc/testsuite/ChangeLog | 15 +++++++++++++++ .../cpp1z/has-unique-obj-representations1.C | 2 +- gcc/testsuite/g++.dg/ext/flexarray-mangle-2.C | 2 +- gcc/testsuite/g++.dg/ext/flexarray-mangle.C | 2 +- gcc/testsuite/g++.dg/ext/flexarray-subst.C | 2 +- gcc/testsuite/g++.dg/ext/flexary10.C | 2 +- gcc/testsuite/g++.dg/ext/flexary11.C | 2 +- gcc/testsuite/g++.dg/ext/flexary14.C | 2 +- gcc/testsuite/g++.dg/ext/flexary16.C | 4 ++-- gcc/testsuite/g++.dg/ext/flexary26.C | 4 ++-- gcc/testsuite/g++.dg/ext/flexary27.C | 4 ++-- gcc/testsuite/g++.dg/ext/flexary7.C | 8 ++++---- gcc/testsuite/g++.dg/ext/pr71290.C | 6 +++--- 15 files changed, 41 insertions(+), 21 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e1167761ffc..75fcc8adc58 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-10-30 Paolo Carlini + + * decl.c (grokdeclarator): Use declarator->id_loc in diagnostic + about flexible array members. + 2018-10-29 David Malcolm * cp-name-hint.h: New file. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 00e75f0bc79..496ed98d9a5 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12210,7 +12210,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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 62a966bab6f..e3fa8007fd1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,18 @@ +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. + 2018-10-30 Paul Koning * gcc.dg/tree-ssa/attr-alias.c: Skip if no weak support. diff --git a/gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C b/gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C index bca03a16c41..e50e535922f 100644 --- a/gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C +++ b/gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations1.C @@ -9,7 +9,7 @@ struct V { int i : INTB * 3 / 4; int j : INTB / 4 + 1; }; 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" } diff --git a/gcc/testsuite/g++.dg/ext/flexarray-mangle-2.C b/gcc/testsuite/g++.dg/ext/flexarray-mangle-2.C index 3abb407fab7..3d534e86c2e 100644 --- a/gcc/testsuite/g++.dg/ext/flexarray-mangle-2.C +++ b/gcc/testsuite/g++.dg/ext/flexarray-mangle-2.C @@ -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. diff --git a/gcc/testsuite/g++.dg/ext/flexarray-mangle.C b/gcc/testsuite/g++.dg/ext/flexarray-mangle.C index 658d9355a9c..9625459f922 100644 --- a/gcc/testsuite/g++.dg/ext/flexarray-mangle.C +++ b/gcc/testsuite/g++.dg/ext/flexarray-mangle.C @@ -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. diff --git a/gcc/testsuite/g++.dg/ext/flexarray-subst.C b/gcc/testsuite/g++.dg/ext/flexarray-subst.C index 6cf03a41af2..8364a3e2922 100644 --- a/gcc/testsuite/g++.dg/ext/flexarray-subst.C +++ b/gcc/testsuite/g++.dg/ext/flexarray-subst.C @@ -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 diff --git a/gcc/testsuite/g++.dg/ext/flexary10.C b/gcc/testsuite/g++.dg/ext/flexary10.C index 4d1ff56e49b..7d71630d46b 100644 --- a/gcc/testsuite/g++.dg/ext/flexary10.C +++ b/gcc/testsuite/g++.dg/ext/flexary10.C @@ -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) diff --git a/gcc/testsuite/g++.dg/ext/flexary11.C b/gcc/testsuite/g++.dg/ext/flexary11.C index f958cc5555a..058c1e7d1e6 100644 --- a/gcc/testsuite/g++.dg/ext/flexary11.C +++ b/gcc/testsuite/g++.dg/ext/flexary11.C @@ -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 () diff --git a/gcc/testsuite/g++.dg/ext/flexary14.C b/gcc/testsuite/g++.dg/ext/flexary14.C index add150a0be8..cda6635d8cf 100644 --- a/gcc/testsuite/g++.dg/ext/flexary14.C +++ b/gcc/testsuite/g++.dg/ext/flexary14.C @@ -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 member" } + int n, a[]; // { dg-error "10:ISO C\\+\\+ forbids flexible array member" } }; void bar (B *b) diff --git a/gcc/testsuite/g++.dg/ext/flexary16.C b/gcc/testsuite/g++.dg/ext/flexary16.C index 64a9f5d0515..94eb6c8c577 100644 --- a/gcc/testsuite/g++.dg/ext/flexary16.C +++ b/gcc/testsuite/g++.dg/ext/flexary16.C @@ -12,7 +12,7 @@ struct container struct incomplete { int x; - elem array[]; // { dg-warning "forbids flexible array member" } + elem array[]; // { dg-warning "10:ISO C\\+\\+ forbids flexible array member" } }; }; @@ -27,7 +27,7 @@ struct D: container { struct S { int x; - typename container::elem array[]; // { dg-warning "forbids flexible array member" } + typename container::elem array[]; // { dg-warning "33:ISO C\\+\\+ forbids flexible array member" } }; }; diff --git a/gcc/testsuite/g++.dg/ext/flexary26.C b/gcc/testsuite/g++.dg/ext/flexary26.C index af1277287aa..e62e221cff5 100644 --- a/gcc/testsuite/g++.dg/ext/flexary26.C +++ b/gcc/testsuite/g++.dg/ext/flexary26.C @@ -2,8 +2,8 @@ // { dg-do compile } // { dg-options "-Wpedantic" } -struct S { const char *a; char b[]; }; // { dg-warning "forbids flexible array member" } -struct T { int a; int b[]; }; // { dg-warning "forbids flexible array member" } +struct S { const char *a; char b[]; }; // { dg-warning "32:ISO C\\+\\+ forbids flexible array member" } +struct T { int a; int b[]; }; // { dg-warning "23:ISO C\\+\\+ forbids flexible array member" } #if __cplusplus >= 201103L S c[] { "", "" }; // { dg-error "initialization of flexible array member in a nested context" "" { target c++11 } } // { dg-warning "initialization of a flexible array member" "" { target c++11 } .-1 } diff --git a/gcc/testsuite/g++.dg/ext/flexary27.C b/gcc/testsuite/g++.dg/ext/flexary27.C index 9dfa9a2b82c..20c04b42f58 100644 --- a/gcc/testsuite/g++.dg/ext/flexary27.C +++ b/gcc/testsuite/g++.dg/ext/flexary27.C @@ -1,8 +1,8 @@ // PR c++/81922 // { dg-do compile } -struct S { const char *a; char b[]; }; // { dg-error "forbids flexible array member" } -struct T { int a; int b[]; }; // { dg-error "forbids flexible array member" } +struct S { const char *a; char b[]; }; // { dg-error "32:ISO C\\+\\+ forbids flexible array member" } +struct T { int a; int b[]; }; // { dg-error "23:ISO C\\+\\+ forbids flexible array member" } #if __cplusplus >= 201103L S c[] { "", "" }; // { dg-error "initialization of flexible array member in a nested context" "" { target c++11 } } // { dg-error "initialization of a flexible array member" "" { target c++11 } .-1 } diff --git a/gcc/testsuite/g++.dg/ext/flexary7.C b/gcc/testsuite/g++.dg/ext/flexary7.C index 1b22f21b2b6..62d869ee7ad 100644 --- a/gcc/testsuite/g++.dg/ext/flexary7.C +++ b/gcc/testsuite/g++.dg/ext/flexary7.C @@ -5,7 +5,7 @@ struct FlexChar { int n; - char a[]; // { dg-warning "forbids flexible array member" } + char a[]; // { dg-warning "10:ISO C\\+\\+ forbids flexible array member" } }; struct FlexChar ac = @@ -18,7 +18,7 @@ typedef __WCHAR_TYPE__ wchar_t; struct FlexWchar { int n; - wchar_t a[]; // { dg-warning "forbids flexible array member" } + wchar_t a[]; // { dg-warning "13:ISO C\\+\\+ forbids flexible array member" } }; struct FlexWchar awc = @@ -27,7 +27,7 @@ struct FlexWchar awc = struct FlexInt { int n; - int a[]; // { dg-warning "forbids flexible array member" } + int a[]; // { dg-warning "9:ISO C\\+\\+ forbids flexible array member" } }; // Verify that no warning is issued for the case when a flexible array @@ -48,7 +48,7 @@ struct FlexInt ai2 = template struct FlexT { int n; - T a[]; // { dg-warning "forbids flexible array member" } + T a[]; // { dg-warning "7:ISO C\\+\\+ forbids flexible array member" } }; struct FlexT atc = diff --git a/gcc/testsuite/g++.dg/ext/pr71290.C b/gcc/testsuite/g++.dg/ext/pr71290.C index e782eb1a486..7268294381c 100644 --- a/gcc/testsuite/g++.dg/ext/pr71290.C +++ b/gcc/testsuite/g++.dg/ext/pr71290.C @@ -1,17 +1,17 @@ // PR c++/71290 - [6/7 Regression] Flexible array member is not diagnosed // with -pedantic -// { dg-do compile }s +// { dg-do compile } // { dg-options "-Wall -Wpedantic" } struct A { int i; - int arr[]; // { dg-warning "forbids flexible array member .arr." } + int arr[]; // { dg-warning "7:ISO C\\+\\+ forbids flexible array member .arr." } }; template struct B { T n; - T a[]; // { dg-warning "forbids flexible array member .a." } + T a[]; // { dg-warning "5:ISO C\\+\\+ forbids flexible array member .a." } }; -- 2.30.2