]> granicus.if.org Git - clang/commitdiff
__declspec(uuid) is only allowed on a class according to MSDN; this makes the semanti...
authorAaron Ballman <aaron@aaronballman.com>
Sun, 24 Nov 2013 20:58:02 +0000 (20:58 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Sun, 24 Nov 2013 20:58:02 +0000 (20:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195579 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/Parser/MicrosoftExtensions.cpp

index 76cbaa297f13531e8aab85e0bb639840c96362b4..1f786471537b88a62862298c25e6bd9fa83871d3 100644 (file)
@@ -4482,6 +4482,12 @@ static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
   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))
index efb5c3ce1fdcbca6523d3a213b8593f86edd54a1..8c1497a9472272c0b0517b7e8fdf3913d80e97a7 100644 (file)
@@ -50,7 +50,7 @@ struct __declspec(uuid("0000000-0000-0000-1234-0000500000047")) uuid_attr_bad3 {
 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 { };