Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11380,8 +11380,11 @@ static bool CheckMultiVersionAdditionalRules(Sema &S, const FunctionDecl *OldFD,
return true;

// Only allow transition to MultiVersion if it hasn't been used.
if (OldFD && CausesMV && OldFD->isUsed(false))
return S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
if (OldFD && CausesMV && OldFD->isUsed(false)) {
S.Diag(NewFD->getLocation(), diag::err_multiversion_after_used);
S.Diag(OldFD->getLocation(), diag::note_previous_declaration);
return true;
}

return S.areMultiversionVariantFunctionsCompatible(
OldFD, NewFD, S.PDiag(diag::err_multiversion_noproto),
Expand Down
3 changes: 2 additions & 1 deletion clang/test/Sema/attr-cpuspecific.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ int allow_fwd_decl2(void);
void use_fwd_decl(void) {
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) {}


Expand Down
3 changes: 2 additions & 1 deletion clang/test/Sema/attr-target-mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ int use3(void) {
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("sse4.2,arch=sandybridge"))) mangle(void) { return 1; }
Expand Down
3 changes: 2 additions & 1 deletion clang/test/Sema/attr-target-version.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ int bar() {
nodef();
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("sve"))) prot();
Expand Down
Loading