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 via email to