+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...
&& (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");
}
}
|| (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");
}
}
--- /dev/null
+/* 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