r254646 - Add tests for `&enable_if_function` diagnostics.
George Burgess IV via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 3 12:54:58 PST 2015
Author: gbiv
Date: Thu Dec 3 14:54:58 2015
New Revision: 254646
URL: http://llvm.org/viewvc/llvm-project?rev=254646&view=rev
Log:
Add tests for `&enable_if_function` diagnostics.
The introduction of pass_object_size fixed a few bugs related to taking
the address of a function with enable_if attributes. This patch adds
tests for the cases that were fixed.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/Sema/enable_if.c
cfe/trunk/test/SemaCXX/enable_if.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=254646&r1=254645&r2=254646&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Dec 3 14:54:58 2015
@@ -8833,7 +8833,6 @@ static bool checkAddressOfFunctionIsAvai
SourceLocation Loc) {
if (!isFunctionAlwaysEnabled(S.Context, FD)) {
if (Complain) {
- // FIXME(gbiv): Both diagnostics below lack tests. We should add tests.
if (InOverloadResolution)
S.Diag(FD->getLocStart(),
diag::note_addrof_ovl_candidate_disabled_by_enable_if_attr);
Modified: cfe/trunk/test/Sema/enable_if.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/enable_if.c?rev=254646&r1=254645&r2=254646&view=diff
==============================================================================
--- cfe/trunk/test/Sema/enable_if.c (original)
+++ cfe/trunk/test/Sema/enable_if.c Thu Dec 3 14:54:58 2015
@@ -136,4 +136,10 @@ void test7() {
void *p3 = (void*)&f3; // expected-error{{address of overloaded function 'f3' does not match required type 'void'}} expected-note at 131{{candidate function made ineligible by enable_if}} expected-note at 132{{candidate function made ineligible by enable_if}}
void *p4 = (void*)f3; // expected-error{{address of overloaded function 'f3' does not match required type 'void'}} expected-note at 131{{candidate function made ineligible by enable_if}} expected-note at 132{{candidate function made ineligible by enable_if}}
}
+
+void f4(int m) __attribute__((enable_if(0, "")));
+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}}
+}
#endif
Modified: cfe/trunk/test/SemaCXX/enable_if.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enable_if.cpp?rev=254646&r1=254645&r2=254646&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enable_if.cpp (original)
+++ cfe/trunk/test/SemaCXX/enable_if.cpp Thu Dec 3 14:54:58 2015
@@ -233,4 +233,23 @@ namespace FnPtrs {
a = templatedConflict<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note at 226{{candidate function}} expected-note at 228{{candidate function}}
a = &templatedConflict<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note at 226{{candidate function}} expected-note at 228{{candidate function}}
}
+
+ int ovlNoCandidate(int m) __attribute__((enable_if(false, "")));
+ int ovlNoCandidate(int m) __attribute__((enable_if(0, "")));
+ void test7() {
+ int (*p)(int) = ovlNoCandidate; // expected-error{{address of overloaded function 'ovlNoCandidate' does not match required type}} expected-note at 237{{made ineligible by enable_if}} expected-note at 238{{made ineligible by enable_if}}
+ int (*p2)(int) = &ovlNoCandidate; // expected-error{{address of overloaded function 'ovlNoCandidate' does not match required type}} expected-note at 237{{made ineligible by enable_if}} expected-note at 238{{made ineligible by enable_if}}
+ int (*a)(int);
+ a = ovlNoCandidate; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note at 237{{made ineligible by enable_if}} expected-note at 238{{made ineligible by enable_if}}
+ a = &ovlNoCandidate; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note at 237{{made ineligible by enable_if}} expected-note at 238{{made ineligible by enable_if}}
+ }
+
+ int noOvlNoCandidate(int m) __attribute__((enable_if(false, "")));
+ void test8() {
+ int (*p)(int) = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ int (*p2)(int) = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ int (*a)(int);
+ a = noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ a = &noOvlNoCandidate; // expected-error{{cannot take address of function 'noOvlNoCandidate' becuase it has one or more non-tautological enable_if conditions}}
+ }
}
More information about the cfe-commits
mailing list