]> granicus.if.org Git - clang/commitdiff
Warn that the [] spelling of uuid(...) is deprecated.
authorNico Weber <nicolasweber@gmx.de>
Fri, 5 May 2017 17:05:56 +0000 (17:05 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 5 May 2017 17:05:56 +0000 (17:05 +0000)
https://reviews.llvm.org/D32879

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@302255 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Parse/ParseDeclCXX.cpp
lib/Sema/SemaDeclAttr.cpp
test/Parser/MicrosoftExtensions.cpp
test/Parser/ms-square-bracket-attributes.mm
test/SemaCXX/ms-uuid.cpp

index 733d792d61019745afb31410c71847c7e66bf44c..00393d78b9efcf6714fde3562a03d41c72e6aacc 100644 (file)
@@ -730,6 +730,9 @@ def err_super_in_lambda_unsupported : Error<
 def warn_pragma_unused_undeclared_var : Warning<
   "undeclared variable %0 used as an argument for '#pragma unused'">,
   InGroup<IgnoredPragmas>;
+def warn_atl_uuid_deprecated : Warning<
+  "specifying 'uuid' as an ATL attribute is deprecated; use __declspec instead">,
+  InGroup<DeprecatedDeclarations>;
 def warn_pragma_unused_expected_var_arg : Warning<
   "only variables can be arguments to '#pragma unused'">,
   InGroup<IgnoredPragmas>;
index b25152a3183e1eac9f175b3edb87161bf38b92c9..ad7b319676e920504e0d434862d1a08c1ec150b1 100644 (file)
@@ -4151,8 +4151,6 @@ void Parser::ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs) {
   }
 
   if (!T.consumeClose()) {
-    // FIXME: Warn that this syntax is deprecated, with a Fix-It suggesting
-    // using __declspec(uuid()) instead.
     Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()), nullptr,
                  SourceLocation(), ArgExprs.data(), ArgExprs.size(),
                  AttributeList::AS_Microsoft);
index 9cbfcd1503a107e396e86f0379e5a0b55840b27f..fa831f8ddf7df3354eb8d199b85b98b420809607 100644 (file)
@@ -5079,6 +5079,15 @@ static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
     }
   }
 
+  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if it's
+  // the only thing in the [] list, the [] too), and add an insertion of
+  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the commas
+  // separating attributes nor of the [ and the ] are in the AST.
+  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]] etc"
+  // on cfe-dev.
+  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
+    S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
+
   UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
                                  Attr.getAttributeSpellingListIndex(), StrRef);
   if (UA)
index 830412ed474f631e066081be7d0fa6ebe188a0fc..74f4bb3268de141ec562252962d5dabbbc095bc7 100644 (file)
@@ -60,7 +60,7 @@ struct struct_without_uuid { };
 struct __declspec(uuid("000000A0-0000-0000-C000-000000000049"))
 struct_with_uuid2;
 
-[uuid("000000A0-0000-0000-C000-000000000049")] struct struct_with_uuid3;
+[uuid("000000A0-0000-0000-C000-000000000049")] struct struct_with_uuid3; // expected-warning{{specifying 'uuid' as an ATL attribute is deprecated; use __declspec instead}}
 
 struct
 struct_with_uuid2 {} ;
index 98b2f6c2d3ea10787beae5d952b5a0ab5d510f92..a158cf7b2b909c0403a2da55d8bfa8e58aa34d31 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s -Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
index 461e3c12ff8a01284ef1fc1e1336d5a158401d66..e29dda878e6803dbe4305a94f8b3bc86f5a2cbfe 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;