]> granicus.if.org Git - clang/commitdiff
__declspec(uuid) is only supported for C++ code according to MSDN (as well as behavio...
authorAaron Ballman <aaron@aaronballman.com>
Sun, 24 Nov 2013 21:35:16 +0000 (21:35 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Sun, 24 Nov 2013 21:35:16 +0000 (21:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195580 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/Sema/MicrosoftExtensions.c

index bf81169b7f8e46646da37bc583e811af1e03f6d8..59a2c19a3a385a66e4bce14003da9fc6a9c0abc7 100644 (file)
@@ -2385,6 +2385,8 @@ def err_attribute_regparm_wrong_platform : Error<
   "'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
index 1f786471537b88a62862298c25e6bd9fa83871d3..4a8b5289317ef253946a2bef8a9eda6ac810209e 100644 (file)
@@ -61,6 +61,14 @@ enum AttributeDeclKind {
   ExpectedType
 };
 
+namespace AttributeLangSupport {
+  enum {
+    C,
+    Cpp,
+    ObjC
+  };
+}
+
 //===----------------------------------------------------------------------===//
 //  Helper functions
 //===----------------------------------------------------------------------===//
@@ -4479,6 +4487,12 @@ static bool checkMicrosoftExt(Sema &S, const AttributeList &Attr,
 }
 
 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;
 
index a6caf7acb8a86733e162528490207748012cb7bc..e672d05d0902cc3706c63dbf3b0b431845e57a43 100644 (file)
@@ -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;