Clang error: invalid cpu feature string for builtin (err_invalid_cpu_supports)
Jump to navigation
Jump to search
Text | error: invalid cpu feature string for builtin |
---|---|
Type | Error |
Category | Semantic Issue |
Internal Id | err_invalid_cpu_supports |
Internal Message | invalid cpu feature string for builtin
|
Regular Expression | (?:error|fatal error)\: invalid cpu feature string for builtin
|
First Commit | 2015-06-29 d983270976d2 Add support for the x86 builtin __builtin_cpu_supports. |
Description
Example
Flags | -xc -march=native -target x86_64-linux-gnu
|
|
---|---|---|
Source |
int main() {
__builtin_cpu_supports("unknown_feature"); // Invalid CPU feature string
}
| |
Compiler Output |
<source>:2:3: error: invalid cpu feature string for builtin |
Clang Internals (17.0.6)
Git Commit Message
Add support for the x86 builtin __builtin_cpu_supports. This matches the implementation of the gcc support for the same feature, including checking the values set up by libgcc at runtime. The structure looks like this: unsigned int __cpu_vendor; unsigned int __cpu_type; unsigned int __cpu_subtype; unsigned int __cpu_features[1]; with a set of enums to match various fields that are field out after parsing the output of the cpuid instruction. This also adds a set of errors checking for valid input (and cpu). compiler-rt support for this and the other builtins in this family (__builtin_cpu_init and __builtin_cpu_is) are forthcoming. llvm-svn: 240994
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/Sema/SemaChecking.cpp (line 5472)
/// SemaBuiltinCpuSupports - Handle __builtin_cpu_supports(char *).
/// This checks that the target supports __builtin_cpu_supports and
/// that the string argument is constant and valid.
static bool SemaBuiltinCpuSupports(Sema &S, const TargetInfo &TI, CallExpr *TheCall) {
// ...
if (!TI.validateCpuSupports(Feature))
return S.Diag(TheCall->getBeginLoc(), diag::err_invalid_cpu_supports) << Arg->getSourceRange();
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/Sema/builtin-cpu-supports.c
- clang/test/Sema/builtin-cpu-supports.c:10:7: error: invalid cpu feature string for builtin