[cfe-commits] r151295 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/CodeGen/ms-declspecs.c test/Sema/MicrosoftCompatibility.c
Aaron Ballman
aaron at aaronballman.com
Thu Feb 23 14:46:33 PST 2012
Author: aaronballman
Date: Thu Feb 23 16:46:33 2012
New Revision: 151295
URL: http://llvm.org/viewvc/llvm-project?rev=151295&view=rev
Log:
Turned on support for __declspecs: noreturn, noinline, nothrow and naked in MS compatibility mode.
Added:
cfe/trunk/test/CodeGen/ms-declspecs.c
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/MicrosoftCompatibility.c
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=151295&r1=151294&r2=151295&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Feb 23 16:46:33 2012
@@ -3463,10 +3463,19 @@
}
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;
+ }
}
//===----------------------------------------------------------------------===//
Added: cfe/trunk/test/CodeGen/ms-declspecs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-declspecs.c?rev=151295&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/ms-declspecs.c (added)
+++ cfe/trunk/test/CodeGen/ms-declspecs.c Thu Feb 23 16:46:33 2012
@@ -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(); }
Modified: cfe/trunk/test/Sema/MicrosoftCompatibility.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftCompatibility.c?rev=151295&r1=151294&r2=151295&view=diff
==============================================================================
--- cfe/trunk/test/Sema/MicrosoftCompatibility.c (original)
+++ cfe/trunk/test/Sema/MicrosoftCompatibility.c Thu Feb 23 16:46:33 2012
@@ -10,3 +10,7 @@
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}}
+}
More information about the cfe-commits
mailing list