diff options
author | Marek Polacek <polacek@redhat.com> | 2017-08-11 18:02:18 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2017-08-11 18:02:18 +0000 |
commit | bb85aa74f07e2cebb7f888a1817eba6f2f4308a6 (patch) | |
tree | a96a1ed51c7758fbdbf7baa89719685232ae1a81 /gcc/c/c-decl.c | |
parent | 27c33b8fa5a882bc3476f6860fb5032ffe208562 (diff) | |
download | gcc-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/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 18 |
1 files changed, 8 insertions, 10 deletions
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"); } } |