From: Ed Smith-Rowland <3dw4rd@verizon.net>
To: Marek Polacek <polacek@redhat.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
"Joseph S. Myers" <joseph@codesourcery.com>,
Jason Merrill <jason@redhat.com>
Subject: Re: C/C++ PATCH to allow deprecating enum values (PR c/47043)
Date: Thu, 07 May 2015 14:22:00 -0000 [thread overview]
Message-ID: <554B74E8.2060900@verizon.net> (raw)
In-Reply-To: <20150507135955.GE3384@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1886 bytes --]
On 05/07/2015 09:59 AM, Marek Polacek wrote:
> On Wed, May 06, 2015 at 11:17:20PM -0400, Ed Smith-Rowland wrote:
>> In addition to a PR this is 1/2 of a C=+17 feature. (The other half - really
>> a separate thing - is attributes on namespaces).
> Ah, nice, I wasn't aware. For the record, this is
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4266.html>.
>
>> I wonder if we should pedwarn for < C++17?
>> Or it could be just an extension for < C++17 - I guess that would match with
>> clang.
>
> Yeah, it is meant as a GNU extension. (clang supports this extension for
> several years already.) I'd rather let Jason decide what to do wrt C++17.
>
>> @@ -3651,11 +3651,6 @@ finish_id_expression (tree id_expression,
>> }
>> }
>>
>> - /* Handle references (c++/56130). */
>> - tree t = REFERENCE_REF_P (decl) ? TREE_OPERAND (decl, 0) : decl;
>> - if (TREE_DEPRECATED (t))
>> - warn_deprecated_use (t, NULL_TREE);
>> -
>> return decl;
>> }
>>
>> Why did this bit get removed?
> This hunk got added in r201906 to address c++/56130 - we didn't warn for
> deprecated references:
>
> int g_nn;
> int& g_n __attribute__((deprecated)) = g_nn;
>
> int main()
> {
> g_n = 1;
> }
>
> But then Jason added warn_deprecated_use to mark_used in r217677 and we
> warned twice. So I figured the warning in finish_id_expression isn't
> needed anymore.
>
>> Do we handle enums in template specializations?
> Not sure, could you provide a testcase? Thanks,
>
> Marek
>
Instead of NULL_TREE in pt.c I grabbed the attrs.
/* Actually build the enumerator itself. */
build_enumerator
(DECL_NAME (decl), value, newtag, DECL_ATTRIBUTES (decl),
DECL_SOURCE_LOCATION (decl));
Seems to work.
Also, I haven't tested the testcase in terms of the pattern matching of
the error. Tweak it if necessary.
Thanks for this.
Ed
[-- Attachment #2: attributes-enum-2.C --]
[-- Type: text/x-c++src, Size: 427 bytes --]
// PR c/47046
// { dg-do compile { target c++11 } }
class C
{
public:
enum Foo
{
T,
U [[deprecated("unused")]],
V
};
};
template<typename Tp>
class D
{
public:
enum Bar
{
X,
Y [[deprecated("unused")]],
Z
};
};
int
f (int i)
{
auto j = C::U; // { dg-warning ".C::U. is deprecated" }
auto k = D<int>::Y; // { dg-warning ".D<int>::Y. is deprecated" }
return i;
}
next prev parent reply other threads:[~2015-05-07 14:22 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-07 3:17 Ed Smith-Rowland
2015-05-07 14:00 ` Marek Polacek
2015-05-07 14:22 ` Ed Smith-Rowland [this message]
2015-05-07 16:22 ` Marek Polacek
2015-05-07 17:25 ` Sandra Loosemore
2015-05-07 19:26 ` Marek Polacek
2015-05-14 8:54 ` Marek Polacek
2015-05-14 21:47 ` Joseph Myers
2015-05-21 11:02 ` Marek Polacek
2015-05-21 18:14 ` Jason Merrill
2015-05-21 18:19 ` Jason Merrill
2015-05-22 9:27 ` Marek Polacek
2015-05-22 23:05 ` Mikhail Maltsev
2015-05-23 20:25 ` Ed Smith-Rowland
-- strict thread matches above, loose matches on Subject: below --
2015-05-06 15:48 Marek Polacek
2015-05-06 16:13 ` Joseph Myers
2015-05-06 18:44 ` Marek Polacek
2015-05-07 11:03 ` Marek Polacek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=554B74E8.2060900@verizon.net \
--to=3dw4rd@verizon.net \
--cc=gcc-patches@gcc.gnu.org \
--cc=jason@redhat.com \
--cc=joseph@codesourcery.com \
--cc=polacek@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).