From 9428772f16e379bcad35254251f96e3d1077c730 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 23 Feb 2012 22:46:33 +0000 Subject: [PATCH] Turned on support for __declspecs: noreturn, noinline, nothrow and naked in MS compatibility mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151295 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclAttr.cpp | 17 +++++++++++++---- test/CodeGen/ms-declspecs.c | 16 ++++++++++++++++ test/Sema/MicrosoftCompatibility.c | 4 ++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 test/CodeGen/ms-declspecs.c diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index daf225978e..f0fcd6e91c 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -3463,10 +3463,19 @@ static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, } static bool isKnownDeclSpecAttr(const AttributeList &Attr) { - return Attr.getKind() == AttributeList::AT_dllimport || - Attr.getKind() == AttributeList::AT_dllexport || - Attr.getKind() == AttributeList::AT_uuid || - Attr.getKind() == AttributeList::AT_deprecated; + switch (Attr.getKind()) { + default: + return false; + case AttributeList::AT_dllimport: + case AttributeList::AT_dllexport: + case AttributeList::AT_uuid: + case AttributeList::AT_deprecated: + case AttributeList::AT_noreturn: + case AttributeList::AT_nothrow: + case AttributeList::AT_naked: + case AttributeList::AT_noinline: + return true; + } } //===----------------------------------------------------------------------===// diff --git a/test/CodeGen/ms-declspecs.c b/test/CodeGen/ms-declspecs.c new file mode 100644 index 0000000000..d3235aee43 --- /dev/null +++ b/test/CodeGen/ms-declspecs.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s + +// CHECK: define void @t3() nounwind noinline naked { +__declspec(naked) void t3() {} + +// CHECK: define void @t22() nounwind +void __declspec(nothrow) t22(); +void t22() {} + +// CHECK: define void @t2() nounwind noinline { +__declspec(noinline) void t2() {} + +// CHECK: call void @f20_t() +// CHECK: noreturn +__declspec(noreturn) void f20_t(void); +void f20(void) { f20_t(); } diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c index c26c3039fd..f148e869ff 100644 --- a/test/Sema/MicrosoftCompatibility.c +++ b/test/Sema/MicrosoftCompatibility.c @@ -10,3 +10,7 @@ enum ENUM2 { ENUM2_b = 0x9FFFFFFF, // expected-warning {{enumerator value is not representable in the underlying type 'int'}} ENUM2_c = 0x100000000 // expected-warning {{enumerator value is not representable in the underlying type 'int'}} }; + +__declspec(noreturn) void f6( void ) { + return; // expected-warning {{function 'f6' declared 'noreturn' should not return}} +} -- 2.50.1