ldc/tests/semantic/target_traits_diag.d

25 lines
1 KiB
D

// Tests diagnostics of __traits(targetCPU) and __traits(targetHasFeature, ...)
// RUN: not %ldc -c -w %s 2>&1 | FileCheck %s
void main()
{
// CHECK: Warning: ignoring arguments for __traits targetCPU
enum a = __traits(targetCPU, 1);
// CHECK: Error: __traits targetHasFeature expects one argument, not 0
enum b = __traits(targetHasFeature);
// CHECK: Error: __traits targetHasFeature expects one argument, not 2
enum c = __traits(targetHasFeature, "fma", 1);
// CHECK: Error: expression expected as argument of __traits targetHasFeature
enum d = __traits(targetHasFeature, main);
// CHECK: Error: string expected as argument of __traits targetHasFeature instead of 1
enum e = __traits(targetHasFeature, 1);
// Diagnostics of an unrecognized feature depends on the LLVM version (LLVM < 3.7 does not warn at all)
// Newer LLVM versions do warn.
// TODO: Re-enable test when LLVM < 3.7 is no longer supported.
// CHE CK: 夜畔' is not a recognized feature for this target (ignoring feature)
enum f = __traits(targetHasFeature, "夜畔");
}