r195580 - __declspec(uuid) is only supported for C++ code according to MSDN (as well as behaviorally in MSVC). This adds a generic diagnostic that we use for uuid, and can use for some other attributes as well, and adds a testcase.
Aaron Ballman
aaron at aaronballman.com
Sun Nov 24 13:35:17 PST 2013
Author: aaronballman
Date: Sun Nov 24 15:35:16 2013
New Revision: 195580
URL: http://llvm.org/viewvc/llvm-project?rev=195580&view=rev
Log:
__declspec(uuid) is only supported for C++ code according to MSDN (as well as behaviorally in MSVC). This adds a generic diagnostic that we use for uuid, and can use for some other attributes as well, and adds a testcase.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=195580&r1=195579&r2=195580&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Nov 24 15:35:16 2013
@@ -2385,6 +2385,8 @@ def err_attribute_regparm_wrong_platform
"'regparm' is not valid on this platform">;
def err_attribute_regparm_invalid_number : Error<
"'regparm' parameter must be between 0 and %0 inclusive">;
+def err_attribute_not_supported_in_lang : Error<
+ "%0 attribute is not supported in %select{C|C++|Objective-C}1">;
// Clang-Specific Attributes
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=195580&r1=195579&r2=195580&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Nov 24 15:35:16 2013
@@ -61,6 +61,14 @@ enum AttributeDeclKind {
ExpectedType
};
+namespace AttributeLangSupport {
+ enum {
+ C,
+ Cpp,
+ ObjC
+ };
+}
+
//===----------------------------------------------------------------------===//
// Helper functions
//===----------------------------------------------------------------------===//
@@ -4479,6 +4487,12 @@ static bool checkMicrosoftExt(Sema &S, c
}
static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+ if (!S.LangOpts.CPlusPlus) {
+ S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_in_lang)
+ << Attr.getName() << AttributeLangSupport::C;
+ return;
+ }
+
if (!checkMicrosoftExt(S, Attr, S.LangOpts.Borland))
return;
Modified: cfe/trunk/test/Sema/MicrosoftExtensions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=195580&r1=195579&r2=195580&view=diff
==============================================================================
--- cfe/trunk/test/Sema/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Sema/MicrosoftExtensions.c Sun Nov 24 15:35:16 2013
@@ -20,10 +20,7 @@ struct D {
int D[];
};
-
-
-
-
+struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) IUnknown {}; /* expected-error {{'uuid' attribute is not supported in C}} */
typedef struct notnested {
long bad1;
More information about the cfe-commits
mailing list