diff options
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 12 | ||||
-rw-r--r-- | clang/test/Sema/builtins-x86.c | 20 |
2 files changed, 28 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 55de70826bc..f4e33c6cb09 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -836,12 +836,16 @@ bool Sema::CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { } bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { + unsigned i = 0, l = 0, u = 0; switch (BuiltinID) { - case X86::BI_mm_prefetch: - // This is declared to take (const char*, int) - return SemaBuiltinConstantArgRange(TheCall, 1, 0, 3); + default: return false; + case X86::BI_mm_prefetch: i = 1; l = 0; u = 3; break; + case X86::BI__builtin_ia32_cmpps: + case X86::BI__builtin_ia32_cmpss: + case X86::BI__builtin_ia32_cmppd: + case X86::BI__builtin_ia32_cmpsd: i = 2; l = 0; u = 31; break; } - return false; + return SemaBuiltinConstantArgRange(TheCall, i, l, u); } /// Given a FunctionDecl's FormatAttr, attempts to populate the FomatStringInfo diff --git a/clang/test/Sema/builtins-x86.c b/clang/test/Sema/builtins-x86.c new file mode 100644 index 00000000000..9929e6135c0 --- /dev/null +++ b/clang/test/Sema/builtins-x86.c @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple=x86_64-apple-darwin -fsyntax-only -verify %s + +typedef float __m128 __attribute__((__vector_size__(16))); +typedef double __m128d __attribute__((__vector_size__(16))); + +__m128 test__builtin_ia32_cmpps(__m128 __a, __m128 __b) { + __builtin_ia32_cmpps(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}} +} + +__m128d test__builtin_ia32_cmppd(__m128d __a, __m128d __b) { + __builtin_ia32_cmppd(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}} +} + +__m128 test__builtin_ia32_cmpss(__m128 __a, __m128 __b) { + __builtin_ia32_cmpss(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}} +} + +__m128d test__builtin_ia32_cmpsd(__m128d __a, __m128d __b) { + __builtin_ia32_cmpsd(__a, __b, 32); // expected-error {{argument should be a value from 0 to 31}} +} |