summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/enable_if.c
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-03-31 00:16:25 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-03-31 00:16:25 +0000
commit21d3bffe299ddb505cd9ae4f78fbdf92d61477c7 (patch)
tree83d9a5c49263ad7aaf4e1744320b32662a213d7e /clang/test/Sema/enable_if.c
parent514594bdd32799628608dec68d0fa8704940d7fa (diff)
downloadbcm5719-llvm-21d3bffe299ddb505cd9ae4f78fbdf92d61477c7.tar.gz
bcm5719-llvm-21d3bffe299ddb505cd9ae4f78fbdf92d61477c7.zip
[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. llvm-svn: 264975
Diffstat (limited to 'clang/test/Sema/enable_if.c')
-rw-r--r--clang/test/Sema/enable_if.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/Sema/enable_if.c b/clang/test/Sema/enable_if.c
index 0cd9c48f42b..4034aa2bfab 100644
--- a/clang/test/Sema/enable_if.c
+++ b/clang/test/Sema/enable_if.c
@@ -142,4 +142,11 @@ void test8() {
void (*p1)(int) = &f4; // expected-error{{cannot take address of function 'f4' becuase it has one or more non-tautological enable_if conditions}}
void (*p2)(int) = f4; // expected-error{{cannot take address of function 'f4' becuase it has one or more non-tautological enable_if conditions}}
}
+
+void regular_enable_if(int a) __attribute__((enable_if(a, ""))); // expected-note 3{{declared here}}
+void PR27122_ext() {
+ regular_enable_if(0, 2); // expected-error{{too many arguments}}
+ regular_enable_if(1, 2); // expected-error{{too many arguments}}
+ regular_enable_if(); // expected-error{{too few arguments}}
+}
#endif
OpenPOWER on IntegriCloud