]> granicus.if.org Git - clang/commit
[Sema] Fix PR27122: ICE with enable_if+ill-formed call.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 31 Mar 2016 00:16:25 +0000 (00:16 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Thu, 31 Mar 2016 00:16:25 +0000 (00:16 +0000)
commit7bbc253b7d872d5e7c2558ac82000ebe3a5c4de0
tree5d2b7aa2f97c0ddd20ac29692092f802c4734c0e
parentfd80727d5056ec2380282081f7dbbed4cbae81ac
[Sema] Fix PR27122: ICE with enable_if+ill-formed call.

In some cases, when we encounter a direct function call with an
incorrect number of arguments, we'll emit a diagnostic, and pretend that
the call to the function was valid. For example, in C:

int foo();
int a = foo(1);

Prior to this patch, we'd get an ICE if foo had an enable_if attribute,
because CheckEnableIf assumes that the number of arguments it gets
passed is valid for the function it's passed. Now, we check that the
number of args looks valid prior to checking enable_if conditions.

This fix was not done inside of CheckEnableIf because the problem
presently can only occur in one caller of CheckEnableIf (ActOnCallExpr).
Additionally, checking inside of CheckEnableIf would make us emit
multiple diagnostics for the same error (one "enable_if failed", one
"you gave this function the wrong number of arguments"), which seems
worse than just complaining about the latter.

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