r187769 - Fix for PR16570: when comparing two function pointers, discard qualifiers when
Eli Friedman
eli.friedman at gmail.com
Fri Aug 9 10:17:37 PDT 2013
On Mon, Aug 5, 2013 at 8:44 PM, Richard Trieu <rtrieu at google.com> wrote:
> Author: rtrieu
> Date: Mon Aug 5 22:44:10 2013
> New Revision: 187769
>
> URL: http://llvm.org/viewvc/llvm-project?rev=187769&view=rev
> Log:
> Fix for PR16570: when comparing two function pointers, discard qualifiers when
> comparing non-reference function parameters. The qualifiers don't matter for
> comparisons.
>
> Added:
> cfe/trunk/test/SemaCXX/function-pointer-arguments.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaOverload.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=187769&r1=187768&r2=187769&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Aug 5 22:44:10 2013
> @@ -2584,9 +2584,17 @@ bool Sema::FunctionArgTypesAreEqual(cons
> for (FunctionProtoType::arg_type_iterator O = OldType->arg_type_begin(),
> N = NewType->arg_type_begin(),
> E = OldType->arg_type_end(); O && (O != E); ++O, ++N) {
> - if (!Context.hasSameType(*O, *N)) {
> - if (ArgPos) *ArgPos = O - OldType->arg_type_begin();
> - return false;
> + if (!(*O)->isReferenceType() && !(*N)->isReferenceType()) {
> + if (!Context.hasSameType(O->getUnqualifiedType(),
> + N->getUnqualifiedType())) {
> + if (ArgPos) *ArgPos = O - OldType->arg_type_begin();
> + return false;
> + }
> + } else {
> + if (!Context.hasSameType(*O, *N)) {
> + if (ArgPos) *ArgPos = O - OldType->arg_type_begin();
> + return false;
> + }
These two branches do the same thing because reference types are never
qualified.
-Eli
More information about the cfe-commits
mailing list