[clang][Sema][FMV] Add a note to the 'cannot become multiversioned' diagnostic (#124364)
... pointing out the previous declaration.
This commit is contained in:
parent
73f9034036
commit
73db9ee1e8
@ -11380,8 +11380,11 @@ static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD,
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Only allow transition to MultiVersion if it hasn't been used.
|
// Only allow transition to MultiVersion if it hasn't been used.
|
||||||
if (OldFD && CausesMV && OldFD->isUsed(false))
|
if (OldFD && CausesMV && OldFD->isUsed(false)) {
|
||||||
return S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
|
S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
|
||||||
|
S.Diag(OldFD->getLocation(), diag::note_previous_declaration);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return S.areMultiversionVariantFunctionsCompatible(
|
return S.areMultiversionVariantFunctionsCompatible(
|
||||||
OldFD, NewFD, S.PDiag(diag::err_multiversion_noproto),
|
OldFD, NewFD, S.PDiag(diag::err_multiversion_noproto),
|
||||||
|
@ -44,7 +44,8 @@ int allow_fwd_decl2(void);
|
|||||||
void use_fwd_decl(void) {
|
void use_fwd_decl(void) {
|
||||||
allow_fwd_decl2();
|
allow_fwd_decl2();
|
||||||
}
|
}
|
||||||
// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
|
// expected-error@+2 {{function declaration cannot become a multiversioned function after first usage}}
|
||||||
|
// expected-note@-5 {{previous declaration is here}}
|
||||||
int __attribute__((cpu_dispatch(atom))) allow_fwd_decl2(void) {}
|
int __attribute__((cpu_dispatch(atom))) allow_fwd_decl2(void) {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,8 @@ int use3(void) {
|
|||||||
return mv_after_use();
|
return mv_after_use();
|
||||||
}
|
}
|
||||||
|
|
||||||
// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
|
// expected-error@+2 {{function declaration cannot become a multiversioned function after first usage}}
|
||||||
|
// expected-note@-6 {{previous declaration is here}}
|
||||||
int __attribute__((target("arch=sandybridge"))) mv_after_use(void) { return 2; }
|
int __attribute__((target("arch=sandybridge"))) mv_after_use(void) { return 2; }
|
||||||
|
|
||||||
int __attribute__((target("sse4.2,arch=sandybridge"))) mangle(void) { return 1; }
|
int __attribute__((target("sse4.2,arch=sandybridge"))) mangle(void) { return 1; }
|
||||||
|
@ -88,7 +88,8 @@ int bar() {
|
|||||||
nodef();
|
nodef();
|
||||||
return def();
|
return def();
|
||||||
}
|
}
|
||||||
// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
|
// expected-error@+2 {{function declaration cannot become a multiversioned function after first usage}}
|
||||||
|
// expected-note@-13 {{previous declaration is here}}
|
||||||
int __attribute__((target_version("sha2"))) def(void) { return 1; }
|
int __attribute__((target_version("sha2"))) def(void) { return 1; }
|
||||||
|
|
||||||
int __attribute__((target_version("sve"))) prot();
|
int __attribute__((target_version("sve"))) prot();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user