diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index bf81169b7f8e46646da37bc583e811af1e03f6d8..59a2c19a3a385a66e4bce14003da9fc6a9c0abc7 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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 diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 1f786471537b88a62862298c25e6bd9fa83871d3..4a8b5289317ef253946a2bef8a9eda6ac810209e 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -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; diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c index a6caf7acb8a86733e162528490207748012cb7bc..e672d05d0902cc3706c63dbf3b0b431845e57a43 100644 --- a/test/Sema/MicrosoftExtensions.c +++ b/test/Sema/MicrosoftExtensions.c @@ -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;