aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-10-14 11:29:33 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-10-14 11:29:33 +0000
commit312f3fa49dd446fc42b3783102a7f956aa0856e7 (patch)
treecff74acc74af1aea1f893294b2c3c981a3d4f4f3
parent77ef339456ff898de80654000f519cbd80735fd3 (diff)
downloadgcc-312f3fa49dd446fc42b3783102a7f956aa0856e7.zip
gcc-312f3fa49dd446fc42b3783102a7f956aa0856e7.tar.gz
gcc-312f3fa49dd446fc42b3783102a7f956aa0856e7.tar.bz2
decl.c (check_tag_decl): Use DECL_SOURCE_LOCATION.
/cp 2019-10-14 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (check_tag_decl): Use DECL_SOURCE_LOCATION. /testsuite 2019-10-14 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/constexpr-union5.C: Test location(s) too. * g++.dg/diagnostic/bitfld2.C: Likewise. * g++.dg/ext/anon-struct1.C: Likewise. * g++.dg/ext/anon-struct6.C: Likewise. * g++.dg/ext/flexary19.C: Likewise. * g++.dg/ext/flexary9.C: Likewise. * g++.dg/template/error17.C: Likewise. From-SVN: r276958
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-union5.C8
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/bitfld2.C2
-rw-r--r--gcc/testsuite/g++.dg/ext/anon-struct1.C4
-rw-r--r--gcc/testsuite/g++.dg/ext/anon-struct6.C4
-rw-r--r--gcc/testsuite/g++.dg/ext/flexary19.C24
-rw-r--r--gcc/testsuite/g++.dg/ext/flexary9.C44
-rw-r--r--gcc/testsuite/g++.dg/template/error17.C2
10 files changed, 61 insertions, 47 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 187935d..2864107 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2019-10-14 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (check_tag_decl): Use DECL_SOURCE_LOCATION.
+
2019-10-14 Jakub Jelinek <jakub@redhat.com>
PR c++/92084
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6f4c589..a9ff427 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4990,9 +4990,9 @@ check_tag_decl (cp_decl_specifier_seq *declspecs,
/* Anonymous unions are objects, so they can have specifiers. */;
SET_ANON_AGGR_TYPE_P (declared_type);
- if (TREE_CODE (declared_type) != UNION_TYPE
- && !in_system_header_at (input_location))
- pedwarn (input_location, OPT_Wpedantic, "ISO C++ prohibits anonymous structs");
+ if (TREE_CODE (declared_type) != UNION_TYPE)
+ pedwarn (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (declared_type)),
+ OPT_Wpedantic, "ISO C++ prohibits anonymous structs");
}
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 093bd17..13988f8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2019-10-14 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/cpp0x/constexpr-union5.C: Test location(s) too.
+ * g++.dg/diagnostic/bitfld2.C: Likewise.
+ * g++.dg/ext/anon-struct1.C: Likewise.
+ * g++.dg/ext/anon-struct6.C: Likewise.
+ * g++.dg/ext/flexary19.C: Likewise.
+ * g++.dg/ext/flexary9.C: Likewise.
+ * g++.dg/template/error17.C: Likewise.
+
2019-10-14 Jakub Jelinek <jakub@redhat.com>
PR c++/92084
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-union5.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-union5.C
index 5779666..53182e6 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-union5.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-union5.C
@@ -23,16 +23,16 @@ SA((a.i == 42));
struct B
{
- struct {
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
int h;
- struct {
+ struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" }
union {
unsigned char i;
int j;
};
int k;
- }; // { dg-warning "anonymous struct" }
- }; // { dg-warning "anonymous struct" }
+ };
+ };
int l;
constexpr B(): h(1), i(2), k(3), l(4) {}
diff --git a/gcc/testsuite/g++.dg/diagnostic/bitfld2.C b/gcc/testsuite/g++.dg/diagnostic/bitfld2.C
index 46d5ee2..88e7ebf 100644
--- a/gcc/testsuite/g++.dg/diagnostic/bitfld2.C
+++ b/gcc/testsuite/g++.dg/diagnostic/bitfld2.C
@@ -6,4 +6,4 @@ template<int> struct A
struct {} : 2; // { dg-error "expected ';' after struct" "expected" }
};
// { dg-error "ISO C.. forbids declaration" "declaration" { target *-*-* } 6 }
-// { dg-error "ISO C.. prohibits anonymous" "anonymous" { target *-*-* } 6 }
+// { dg-error "10:ISO C.. prohibits anonymous" "anonymous" { target *-*-* } 6 }
diff --git a/gcc/testsuite/g++.dg/ext/anon-struct1.C b/gcc/testsuite/g++.dg/ext/anon-struct1.C
index 0a682db..ceeb8e1 100644
--- a/gcc/testsuite/g++.dg/ext/anon-struct1.C
+++ b/gcc/testsuite/g++.dg/ext/anon-struct1.C
@@ -19,7 +19,7 @@ char testD[sizeof(C::D) == sizeof(A) ? 1 : -1];
/* GNU extension. */
struct E {
- struct { char z; }; /* { dg-error "prohibits anonymous structs" } */
+ struct { char z; }; /* { dg-error "10:ISO C\\+\\+ prohibits anonymous structs" } */
char e;
};
@@ -45,6 +45,6 @@ char testH[sizeof(H) == 2 * sizeof(A) ? 1 : -1];
/* Make sure __extension__ gets turned back off. */
struct I {
- struct { char z; }; /* { dg-error "prohibits anonymous structs" } */
+ struct { char z; }; /* { dg-error "10:ISO C\\+\\+ prohibits anonymous structs" } */
char i;
};
diff --git a/gcc/testsuite/g++.dg/ext/anon-struct6.C b/gcc/testsuite/g++.dg/ext/anon-struct6.C
index 360f250..fad508a 100644
--- a/gcc/testsuite/g++.dg/ext/anon-struct6.C
+++ b/gcc/testsuite/g++.dg/ext/anon-struct6.C
@@ -3,8 +3,8 @@
struct A
{
struct
- {
+ { // { dg-error "3:ISO C\\+\\+ prohibits anonymous structs" }
struct { static int i; }; // { dg-error "prohibits anonymous structs|non-static data members|unnamed class" }
void foo() { i; } // { dg-error "public non-static data" }
- }; // { dg-error "prohibits anonymous structs" }
+ };
};
diff --git a/gcc/testsuite/g++.dg/ext/flexary19.C b/gcc/testsuite/g++.dg/ext/flexary19.C
index 5eaf11b..abfbc43 100644
--- a/gcc/testsuite/g++.dg/ext/flexary19.C
+++ b/gcc/testsuite/g++.dg/ext/flexary19.C
@@ -146,13 +146,13 @@ struct S16
{
int i;
- struct { // { dg-warning "invalid use" }
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" }
// A flexible array as a sole member of an anonymous struct is
// rejected with an error in C mode but emits just a pedantic
// warning in C++. Other than excessive pedantry there is no
// reason to reject it.
int a[];
- }; // { dg-warning "anonymous struct" }
+ };
};
struct S17
@@ -177,9 +177,9 @@ struct S19
{
int i;
- struct { // { dg-warning "invalid use" }
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" }
int j, a[]; // { dg-message "declared here" }
- }; // { dg-warning "anonymous struct" }
+ };
};
struct S20
@@ -198,10 +198,10 @@ struct S21
static int i;
typedef int A[];
- struct { // { dg-warning "invalid use" }
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" }
int j;
A a; // { dg-message "declared here" }
- }; // { dg-warning "anonymous struct" }
+ };
};
struct S22
@@ -215,11 +215,11 @@ struct S22
struct S23
{
- struct {
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
static int i; // { dg-error "static data member" }
int a[]; // { dg-error "in an otherwise empty" }
- }; // { dg-warning "anonymous struct" }
+ };
};
struct S24
@@ -296,11 +296,11 @@ union A
union B
{
- struct {
- struct { // { dg-warning "invalid use" }
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
+ struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct|invalid use" }
int i, a[]; // { dg-message "declared here" }
- }; // { dg-warning "anonymous struct" }
- }; // { dg-warning "anonymous struct" }
+ };
+ };
int j;
};
diff --git a/gcc/testsuite/g++.dg/ext/flexary9.C b/gcc/testsuite/g++.dg/ext/flexary9.C
index 5ebcdf5..b31e84b 100644
--- a/gcc/testsuite/g++.dg/ext/flexary9.C
+++ b/gcc/testsuite/g++.dg/ext/flexary9.C
@@ -282,64 +282,64 @@ struct S_S_S_x {
struct Anon1 {
int n;
- struct { // { dg-warning "invalid use \[^\n\r\]* with a zero-size array" }
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use \[^\n\r\]* with a zero-size array" }
int good[0]; // { dg-warning "forbids zero-size array" }
- }; // { dg-warning "anonymous struct" }
+ };
};
ASSERT_AT_END (Anon1, good);
struct Anon2 {
- struct { // { dg-warning "invalid use" }
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" }
int n;
- struct {
+ struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" }
int good[0]; // { dg-warning "zero-size array" }
- }; // { dg-warning "anonymous struct" }
- }; // { dg-warning "anonymous struct" }
+ };
+ };
};
ASSERT_AT_END (Anon2, good);
struct Anon3 {
- struct { // { dg-warning "invalid use" }
- struct {
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct|invalid use" }
+ struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" }
int n;
int good[0]; // { dg-warning "zero-size array" }
- }; // { dg-warning "anonymous struct" }
- }; // { dg-warning "anonymous struct" }
+ };
+ };
};
ASSERT_AT_END (Anon3, good);
struct Anon4 {
- struct {
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
int in_empty_struct[0]; // { dg-warning "zero-size array|in an otherwise empty" }
- }; // { dg-warning "anonymous struct" }
+ };
};
struct Anon5 {
- struct {
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
int not_at_end[0]; // { dg-warning "zero-size array|not at end" }
- }; // { dg-warning "anonymous struct" }
+ };
int n;
};
struct Anon6 {
- struct {
- struct {
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
+ struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" }
int not_at_end[0]; // { dg-warning "zero-size array|not at end" }
- }; // { dg-warning "anonymous struct" }
+ };
int n;
- }; // { dg-warning "anonymous struct" }
+ };
};
struct Anon7 {
- struct {
- struct {
+ struct { // { dg-warning "10:ISO C\\+\\+ prohibits anonymous struct" }
+ struct { // { dg-warning "12:ISO C\\+\\+ prohibits anonymous struct" }
int not_at_end[0]; // { dg-warning "zero-size array|not at end" }
- }; // { dg-warning "anonymous struct" }
- }; // { dg-warning "anonymous struct" }
+ };
+ };
int n;
};
diff --git a/gcc/testsuite/g++.dg/template/error17.C b/gcc/testsuite/g++.dg/template/error17.C
index 5b3281a..7803a1e 100644
--- a/gcc/testsuite/g++.dg/template/error17.C
+++ b/gcc/testsuite/g++.dg/template/error17.C
@@ -4,6 +4,6 @@ template <typename T>
void
foo()
{
- union { struct { }; }; // { dg-error "prohibits anonymous struct" "anon" }
+ union { struct { }; }; // { dg-error "18:ISO C\\+\\+ prohibits anonymous struct" }
// { dg-error "18:anonymous struct not inside" "not inside" { target *-*-* } .-1 }
}