mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 07:16:07 +00:00

This patch makes unsupported target attributes emit a warning and ignore the target attribute during semantic checks. The changes include: 1. Adding the RISCVTargetInfo::isValidFeatureName function. 2. Rejecting non-full-arch strings in the handleFullArchString function. 3. Adding test cases to demonstrate the warning behavior.
19 lines
1.1 KiB
C
19 lines
1.1 KiB
C
// RUN: %clang_cc1 -triple riscv64-linux-gnu -target-feature +i -fsyntax-only -verify -std=c2x %s
|
|
|
|
//expected-note@+1 {{previous definition is here}}
|
|
int __attribute__((target("arch=rv64g"))) foo(void) { return 0; }
|
|
//expected-error@+1 {{redefinition of 'foo'}}
|
|
int __attribute__((target("arch=rv64gc"))) foo(void) { return 0; }
|
|
|
|
//expected-warning@+1 {{unsupported 'notafeature' in the 'target' attribute string; 'target' attribute ignored}}
|
|
int __attribute__((target("arch=+notafeature"))) UnsupportFeature(void) { return 0; }
|
|
|
|
//expected-warning@+1 {{unsupported 'notafeature' in the 'target' attribute string; 'target' attribute ignored}}
|
|
int __attribute__((target("arch=-notafeature"))) UnsupportNegativeFeature(void) { return 0; }
|
|
|
|
//expected-warning@+1 {{unsupported 'arch=+zba,zbb' in the 'target' attribute string; 'target' attribute ignored}}
|
|
int __attribute__((target("arch=+zba,zbb"))) WithoutPlus(void) { return 0; }
|
|
|
|
//expected-warning@+1 {{unsupported 'arch=zba' in the 'target' attribute string; 'target' attribute ignored}}
|
|
int __attribute__((target("arch=zba"))) WithoutPlus2(void) { return 0; }
|