[clang] Add missing diagnostics for invalid overloads of multiversion functions in C.
authorTom Honermann <tom.honermann@intel.com>
Wed, 9 Feb 2022 23:02:13 +0000 (15:02 -0800)
committerTom Honermann <tom@honermann.net>
Mon, 21 Mar 2022 17:39:43 +0000 (13:39 -0400)
commit8b6f1cbb21c58e255156aa32ac55530c807055a9
tree5cacfe1adb2dc2600371ed300122103c942878ad
parent42e4c5b2610d0008d52f2ebf08961e8ae0adb58b
[clang] Add missing diagnostics for invalid overloads of multiversion functions in C.

Previously, an attempt to declare an overload of a multiversion function
in C was not properly diagnosed. In some cases, diagnostics were simply
missing. In other cases the following assertion failure occured...
```
Assertion `(Previous.empty() || llvm::any_of(Previous, [](const NamedDecl *ND) { return ND->hasAttr(); })) && "Non-redecls shouldn't happen without overloadable present"' failed.
```
... or the following diagnostic was spuriously issued.
```
error: at most one overload for a given name may lack the 'overloadable' attribute
```

The diagnostics issued in some cases could be improved. When the function
type of a redeclaration does not match the prior declaration, it would be
preferable to diagnose the type mismatch before diagnosing mismatched
attributes. Diagnostics are also missing for some cases.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D121959
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/attr-cpuspecific.c
clang/test/Sema/attr-target-clones.c
clang/test/Sema/attr-target-mv.c