[Patch] PR14995 Too eagerly rejects operator function templates

Arthur O'Dwyer arthur.j.odwyer at gmail.com
Thu Jan 30 09:59:51 PST 2014


Hi Rahul,

  Does your patch fix the other two examples given in PR14995? Perhaps they
should also be added as regression tests.
(Just from eyeballing the code, I think your patch *does* fix them,
including my example where the T is dependent on a class template instead
of on a function template; but it might be nice to test explicitly.)

LGTM.

–Arthur



On Thu, Jan 30, 2014 at 6:55 AM, Rahul Jain <rahul1.jain at samsung.com> wrote:

>
>
> Hi,
>
> This patch fixes PR14995 - Too eagerly rejects operator function
> templates.
>
> Please help review the same.
>
>
>
> Index: lib/Sema/SemaDeclCXX.cpp
> ===================================================================
> --- lib/Sema/SemaDeclCXX.cpp (revision 200465)
> +++ lib/Sema/SemaDeclCXX.cpp (working copy)
> @@ -10913,7 +10913,11 @@
>      if (const BuiltinType *BT =
> LastParam->getType()->getAs<BuiltinType>())
>        ParamIsInt = BT->getKind() == BuiltinType::Int;
>
> -    if (!ParamIsInt)
> +    bool ParamIsDependent = false;
> +    if (LastParam->getType()->isDependentType())
> +      ParamIsDependent = true;
> +
> +    if (!ParamIsInt && !ParamIsDependent)
>        return Diag(LastParam->getLocation(),
>                    diag::err_operator_overload_post_incdec_must_be_int)
>          << LastParam->getType() << (Op == OO_MinusMinus);
> Index: test/SemaCXX/overloaded-operator.cpp
> ===================================================================
> --- test/SemaCXX/overloaded-operator.cpp (revision 200465)
> +++ test/SemaCXX/overloaded-operator.cpp (working copy)
> @@ -452,3 +452,16 @@
>      Result = 1; // expected-error {{no viable overloaded '='}} //
> expected-note {{type 'PointerUnion<int *, float *>' is incomplete}}
>    }
>  }
> +
> +namespace PR14995 {
> +
> +  struct B {};
> +  template<typename ...T> void operator++(B, T...) {}
> +
> +  void f() {
> +    B b;
> +    b++;  // ok
> +    ++b;  // ok
> +  }
> +}
> +
>
>
>
>
>
> Thanks,
>
> Rahul
>
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140130/b8a28cd2/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 201401302024474_BGFC2LL5.gif
Type: image/gif
Size: 14036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140130/b8a28cd2/attachment.gif>


More information about the cfe-commits mailing list