This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PING: [PATCH: c++/diagnostic/18313] Warn for pointless qualifiers on return type


Dirk Mueller wrote:

>> ?  Also, what does this do with templates:
>>   template <typename T>
>>   void f() {
>>     T (*p)();
>>   }
>>
>>   f<const int>()
>>
>> ?
> 
> It doesn't warn about anything template related.

In general, what we do is warn at template-declaration time only if we
are sure the warning will make sense for all instantiations, and,
otherwise, warn at template-instantiation time if the warning makes
sense for that specific instantiation.  Here, I think we should warn at
instantiation-time, since, in the presence of dependent types, we don't
what's a class, or what the cv-qualification may be.

However, as I understand it, your code won't warn about even:

  template <typename T>
  void f() {
    extern const int g();
  }

because we're in an template when we declare "g".  If that's correct, I
think we need a different approach, so that we do warn at substitution-time.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]