aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2017-08-11 18:02:18 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2017-08-11 18:02:18 +0000
commitbb85aa74f07e2cebb7f888a1817eba6f2f4308a6 (patch)
treea96a1ed51c7758fbdbf7baa89719685232ae1a81 /gcc
parent27c33b8fa5a882bc3476f6860fb5032ffe208562 (diff)
downloadgcc-bb85aa74f07e2cebb7f888a1817eba6f2f4308a6.zip
gcc-bb85aa74f07e2cebb7f888a1817eba6f2f4308a6.tar.gz
gcc-bb85aa74f07e2cebb7f888a1817eba6f2f4308a6.tar.bz2
re PR c/81795 (Stray "originally defined here" when using -Wc++-compat with #pragma GCC diagnostic push/pop)
PR c/81795 * c-decl.c (pushtag): Only print inform if the warning was printed. (grokdeclarator): Likewise. * gcc.dg/pr81795.c: New test. From-SVN: r251056
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-decl.c18
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr81795.c14
4 files changed, 33 insertions, 10 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 6e29334..cd0c128e 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2017-08-11 Marek Polacek <polacek@redhat.com>
+
+ PR c/81795
+ * c-decl.c (pushtag): Only print inform if the warning was printed.
+ (grokdeclarator): Likewise.
+
2017-08-10 David Malcolm <dmalcolm@redhat.com>
* c-parser.c (c_parser_error): Rename to...
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index d21fbc5..323d448 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -1557,11 +1557,10 @@ pushtag (location_t loc, tree name, tree type)
&& (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl))
!= TYPE_MAIN_VARIANT (type)))
{
- warning_at (loc, OPT_Wc___compat,
- ("using %qD as both a typedef and a tag is "
- "invalid in C++"),
- b->decl);
- if (b->locus != UNKNOWN_LOCATION)
+ if (warning_at (loc, OPT_Wc___compat,
+ ("using %qD as both a typedef and a tag is "
+ "invalid in C++"), b->decl)
+ && b->locus != UNKNOWN_LOCATION)
inform (b->locus, "originally defined here");
}
}
@@ -6596,11 +6595,10 @@ grokdeclarator (const struct c_declarator *declarator,
|| (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b)))
&& TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type))
{
- warning_at (declarator->id_loc, OPT_Wc___compat,
- ("using %qD as both a typedef and a tag is "
- "invalid in C++"),
- decl);
- if (b->locus != UNKNOWN_LOCATION)
+ if (warning_at (declarator->id_loc, OPT_Wc___compat,
+ ("using %qD as both a typedef and a tag is "
+ "invalid in C++"), decl)
+ && b->locus != UNKNOWN_LOCATION)
inform (b->locus, "originally defined here");
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 71b7c62..056953e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-11 Marek Polacek <polacek@redhat.com>
+
+ PR c/81795
+ * gcc.dg/pr81795.c: New test.
+
2017-08-11 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/60355
diff --git a/gcc/testsuite/gcc.dg/pr81795.c b/gcc/testsuite/gcc.dg/pr81795.c
new file mode 100644
index 0000000..b035bd0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr81795.c
@@ -0,0 +1,14 @@
+/* PR c/81795 */
+/* { dg-do compile } */
+/* { dg-options "-Wc++-compat" } */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wc++-compat"
+
+struct S { int f; }; /* { dg-bogus "note: originally defined here" } */
+typedef int S; /* { dg-bogus "invalid in C\[+\]\[+\]" } */
+
+typedef int T; /* { dg-bogus "note: originally defined here" } */
+struct T { int f; }; /* { dg-bogus "invalid in C\[+\]\[+\]" } */
+
+#pragma GCC diagnostic pop