]> granicus.if.org Git - clang/commit
[Sema] Fix an overload resolution bug with enable_if.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Tue, 10 May 2016 01:59:34 +0000 (01:59 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Tue, 10 May 2016 01:59:34 +0000 (01:59 +0000)
commit99582718215387e7231316f3e22de9e6709cc01c
tree7e4a4b80732c6da96ea4f8c92ac924d080fec661
parent9f69b633109a9ef6c0cf63861e980109009fb731
[Sema] Fix an overload resolution bug with enable_if.

Currently, if clang::isBetterOverloadCandidate encounters an enable_if
attribute on either candidate that it's inspecting, it will ignore all
lower priority attributes (e.g. pass_object_size). This is problematic
in cases like:

```
void foo(char *c) __attribute__((enable_if(1, "")));
void foo(char *c __attribute__((pass_object_size(0))))
    __attribute__((enable_if(1, "")));
```

...Because we would ignore the pass_object_size attribute in the second
`foo`, and consider any call to `foo` to be ambiguous.

This patch makes overload resolution consult further tiebreakers (e.g.
pass_object_size) if two candidates have equally good enable_if
attributes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269005 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Sema/SemaOverload.cpp
test/CodeGen/enable_if.c