From 0c6ed3d29b786cad664b165ec9b90b35f5fe33ea Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Tue, 23 Jun 2015 21:10:24 +0000 Subject: [PATCH] Improve error handling for PR22560. The ARM _MoveToCoprocessor and _MoveFromCoprocessor builtins require integer constants for most arguments, but clang was not checking that. With this change, we now report meaningful errors instead of crashing in the backend. llvm-svn: 240463 --- clang/include/clang/Basic/BuiltinsARM.def | 8 ++++---- clang/test/Sema/arm-microsoft-intrinsics.c | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 clang/test/Sema/arm-microsoft-intrinsics.c diff --git a/clang/include/clang/Basic/BuiltinsARM.def b/clang/include/clang/Basic/BuiltinsARM.def index 0610d47..c9cdb4b 100644 --- a/clang/include/clang/Basic/BuiltinsARM.def +++ b/clang/include/clang/Basic/BuiltinsARM.def @@ -105,10 +105,10 @@ LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveFromCoprocessor, "UiUiUiUiUiUi", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveFromCoprocessor2, "UiUiUiUiUiUi", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveToCoprocessor, "vUiUiUiUiUiUi", "", ALL_MS_LANGUAGES) -LANGBUILTIN(_MoveToCoprocessor2, "vUiUiUiUiUiUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveToCoprocessor, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) +LANGBUILTIN(_MoveToCoprocessor2, "vUiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) #undef BUILTIN #undef LANGBUILTIN diff --git a/clang/test/Sema/arm-microsoft-intrinsics.c b/clang/test/Sema/arm-microsoft-intrinsics.c new file mode 100644 index 0000000..0637d98 --- /dev/null +++ b/clang/test/Sema/arm-microsoft-intrinsics.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple armv7 -fms-extensions -fsyntax-only -ffreestanding -verify %s + +unsigned int test_MoveFromCoprocessor(const unsigned int value) { + return _MoveFromCoprocessor(value, 1, 2, 3, 4); // expected-error-re {{argument to {{.*}} must be a constant integer}} +} + +void test_MoveToCoprocessor(const unsigned int value) { + _MoveToCoprocessor(1, 2, value, 3, 4, 5); // expected-error-re {{argument to {{.*}} must be a constant integer}} +} -- 2.7.4