Hi Jason,

I made a little improvement of my fix by including template
type parameter to not dropping cv-const because they are similar to dependent
type which you cannot determine whether they are top-level cv-qualifier or not
until instantiation.

+         if (processing_template_decl
+               && (TREE_CODE (type) == TYPENAME_TYPE
+                  || TREE_CODE (type) == DECLTYPE_TYPE
++                  || TREE_CODE (type) == TEMPLATE_TYPE_PARM  // this is new
+                  )
+            )

1. It fix your test case of
template <class T>
struct A{
   void f(T);
};
template <class T>
void A<T>::f(const T){ }
template<>
void A<int[]>::f(const int*){}

current GCC mistakenly accepts without considering the gap of missing "const"
between declaration and out of line definition. clang correctly rejects it.
(https://www.godbolt.org/z/qb9Tf99eK) and explains the cause nicely.
My fix also rejects it.

2. It also fix a more obvious core1001 issue of free function as my previous fix
only deals with typename/decltype cases.
template<class T>
void f(const T){}
template<>
void f<int[3]>(const int*){}

Your comment is appreciated.

thank you

Reply via email to