public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc-patches@gcc.gnu.org>, Jason Merrill <jason@redhat.com>
Subject: Re: [PATCH] Add gnu::diagnose_as attribute
Date: Mon, 5 Jul 2021 16:18:42 +0200	[thread overview]
Message-ID: <4558474.TO5rdG3zkT@excalibur> (raw)
In-Reply-To: <16bf94b5-cda3-08df-144b-739fa1c0ce3f@redhat.com>

On Thursday, 1 July 2021 17:18:26 CEST Jason Merrill wrote:
> You probably want to adjust is_late_template_attribute to change that.

Right, I hacked is_late_template_attribute but now I only see a TYPE_DECL 
passed to my attribute handler (!DECL_ALIAS_TEMPLATE_P). I.e. I don't know how 
your previous comment is supposed to help me:

On Tuesday, 22 June 2021 22:12:42 CEST Jason Merrill wrote:
> Yes.  You can check that with get_underlying_template.

FWIW, I don't feel qualified to implement the diagnose_as attribute on alias 
templates. The trees I've seen while testing the following test case don't 
make sense to me. :(


// { dg-do compile { target c++11 } }
// { dg-options "-fdiagnostics-use-aliases -fpretty-templates" }

template <typename T> class A0 {};
template <typename T> using B0 [[gnu::diagnose_as]] = A0<T>; // #1
template <typename T> using C0 [[gnu::diagnose_as]] = A0<T*>; // #2

template <typename T> class A1 {};
template <typename T> class A1<T*> {};
template <typename T> using B1 [[gnu::diagnose_as]] = A1<T*>; // #3

void fn_1(int);

int main ()
{
  fn_1 (A0<float> ()); // { dg-error "cannot convert 'B0<float>' to 'int'" }
  fn_1 (A1<float> ()); // { dg-error "cannot convert 'A1<float>' to 'int'" }
  fn_1 (A1<float*> ()); // { dg-error "cannot convert 'B1<float>' to 'int'" }
}


On #1 I see !COMPLETE_TYPE_P (TREE_TYPE (*node)) while on #3 TREE_TYPE (*node) 
is a complete type. Like I said, I don't get to see the TEMPLATE_DECL of 
either #1, #2, or #3, only a TYPE_DECL whose TREE_TYPE is A0. I thus have no 
idea how to reject #2.

-- 
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 std::experimental::simd              https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────

  reply	other threads:[~2021-07-05 14:18 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <14205410.xuKvIAzr1H@excalibur>
     [not found] ` <20210427094648.GL3008@redhat.com>
2021-05-04 11:13   ` Matthias Kretz
2021-05-04 13:34     ` David Malcolm
2021-05-04 14:23       ` Matthias Kretz
2021-05-04 14:32         ` Matthias Kretz
2021-05-04 19:00         ` David Malcolm
2021-05-04 19:22           ` Matthias Kretz
2021-05-14 16:05     ` Martin Sebor
2021-05-26 21:33       ` Matthias Kretz
2021-05-27 17:39     ` Jason Merrill
2021-05-27 18:54       ` Matthias Kretz
2021-05-27 21:15         ` Jason Merrill
2021-05-27 22:07           ` Matthias Kretz
2021-05-28  3:05             ` Jason Merrill
2021-05-28  7:42               ` Matthias Kretz
2021-06-01 19:12                 ` Jason Merrill
2021-06-01 21:01                   ` Matthias Kretz
2021-06-11 10:01                   ` Matthias Kretz
2021-06-15 15:51                     ` Jason Merrill
2021-06-15 20:56                       ` Matthias Kretz
2021-06-16  0:48                         ` Jason Merrill
2021-06-22  7:30                           ` Matthias Kretz
2021-06-22 19:52                             ` Jason Merrill
2021-06-22 20:01                               ` Matthias Kretz
2021-06-22 20:12                                 ` Jason Merrill
2021-07-01  9:28                                   ` Matthias Kretz
2021-07-01 15:18                                     ` Jason Merrill
2021-07-05 14:18                                       ` Matthias Kretz [this message]
2021-07-07 22:34                                         ` Jason Merrill
2021-07-07  8:23                               ` Matthias Kretz
2021-07-08  1:19                                 ` Jason Merrill

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=4558474.TO5rdG3zkT@excalibur \
    --to=m.kretz@gsi.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@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).