Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -2678,6 +2678,10 @@ // C's _Noreturn is allowed to be added to a function after it is defined. ++I; continue; + } else if (isa(NewAttribute)) { + // msvc will allow a subsequent definition to add an uuid to a class + ++I; + continue; } else if (const AlignedAttr *AA = dyn_cast(NewAttribute)) { if (AA->isAlignas()) { // C++11 [dcl.align]p6: Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -5394,9 +5394,11 @@ if (const auto *UA = D->getAttr()) { if (UA->getGuid().equals_lower(Uuid)) return nullptr; - Diag(UA->getLocation(), diag::err_mismatched_uuid); - Diag(CI.getLoc(), diag::note_previous_uuid); - D->dropAttr(); + if (!UA->getGuid().empty()) { + Diag(UA->getLocation(), diag::err_mismatched_uuid); + Diag(CI.getLoc(), diag::note_previous_uuid); + D->dropAttr(); + } } return ::new (Context) UuidAttr(Context, CI, Uuid); Index: clang/test/SemaCXX/ms-uuid.cpp =================================================================== --- clang/test/SemaCXX/ms-uuid.cpp +++ clang/test/SemaCXX/ms-uuid.cpp @@ -106,3 +106,9 @@ } } + +// Test class/struct redeclaration where the subsequent +// declaration has a uuid attribute +struct X{}; + +struct __declspec(uuid("00000000-0000-0000-0000-000000000000")) X; \ No newline at end of file