r195579 - __declspec(uuid) is only allowed on a class according to MSDN; this makes the semantic checking consistent with what the attribute specifies in Attr.td. Also adds a test case.
Aaron Ballman
aaron at aaronballman.com
Sun Nov 24 12:58:02 PST 2013
Author: aaronballman
Date: Sun Nov 24 14:58:02 2013
New Revision: 195579
URL: http://llvm.org/viewvc/llvm-project?rev=195579&view=rev
Log:
__declspec(uuid) is only allowed on a class according to MSDN; this makes the semantic checking consistent with what the attribute specifies in Attr.td. Also adds a test case.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Parser/MicrosoftExtensions.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=195579&r1=195578&r2=195579&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sun Nov 24 14:58:02 2013
@@ -4482,6 +4482,12 @@ static void handleUuidAttr(Sema &S, Decl
if (!checkMicrosoftExt(S, Attr, S.LangOpts.Borland))
return;
+ if (!isa<CXXRecordDecl>(D)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
+ << Attr.getName() << ExpectedClass;
+ return;
+ }
+
StringRef StrRef;
SourceLocation LiteralLoc;
if (!S.checkStringLiteralArgumentAttr(Attr, 0, StrRef, &LiteralLoc))
Modified: cfe/trunk/test/Parser/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/MicrosoftExtensions.cpp?rev=195579&r1=195578&r2=195579&view=diff
==============================================================================
--- cfe/trunk/test/Parser/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/Parser/MicrosoftExtensions.cpp Sun Nov 24 14:58:02 2013
@@ -50,7 +50,7 @@ struct __declspec(uuid("0000000-0000-000
struct __declspec(uuid("0000000-0000-0000-Z234-000000000047")) uuid_attr_bad4 { };// expected-error {{uuid attribute contains a malformed GUID}}
struct __declspec(uuid("000000000000-0000-1234-000000000047")) uuid_attr_bad5 { };// expected-error {{uuid attribute contains a malformed GUID}}
-
+__declspec(uuid("000000A0-0000-0000-C000-000000000046")) int i; // expected-warning {{'uuid' attribute only applies to classes}}
struct __declspec(uuid("000000A0-0000-0000-C000-000000000046"))
struct_with_uuid { };
More information about the cfe-commits
mailing list