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. llvm-svn: 254646
This commit is contained in:
parent
93fc520339
commit
c3ec9508ea
|
@ -8833,7 +8833,6 @@ static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD,
|
|||
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);
|
||||
|
|
|
@ -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@131{{candidate function made ineligible by enable_if}} expected-note@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@131{{candidate function made ineligible by enable_if}} expected-note@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
|
||||
|
|
|
@ -233,4 +233,23 @@ namespace FnPtrs {
|
|||
a = templatedConflict<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@226{{candidate function}} expected-note@228{{candidate function}}
|
||||
a = &templatedConflict<int>; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@226{{candidate function}} expected-note@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@237{{made ineligible by enable_if}} expected-note@238{{made ineligible by enable_if}}
|
||||
int (*p2)(int) = &ovlNoCandidate; // expected-error{{address of overloaded function 'ovlNoCandidate' does not match required type}} expected-note@237{{made ineligible by enable_if}} expected-note@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@237{{made ineligible by enable_if}} expected-note@238{{made ineligible by enable_if}}
|
||||
a = &ovlNoCandidate; // expected-error{{assigning to 'int (*)(int)' from incompatible type '<overloaded function type>'}} expected-note@237{{made ineligible by enable_if}} expected-note@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}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue