diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -56,6 +56,15 @@ if (OwnedType) *OwnedType = DS.isTypeSpecOwned() ? DS.getRepAsDecl() : nullptr; + // Move declspec attributes to ParsedAttributes + llvm::SmallVector ToBeMoved; + for (ParsedAttr &AL : DS.getAttributes()) + if (AL.isDeclspecAttribute()) + ToBeMoved.push_back(&AL); + + for (ParsedAttr *AL : ToBeMoved) + Attrs->takeOneFrom(DS.getAttributes(), AL); + // Parse the abstract-declarator, if present. Declarator DeclaratorInfo(DS, ParsedAttributesView::none(), Context); ParseDeclarator(DeclaratorInfo); diff --git a/clang/test/SemaCXX/using-declspec.cpp b/clang/test/SemaCXX/using-declspec.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaCXX/using-declspec.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fms-compatibility -fsyntax-only -verify %s +// expected-no-diagnostics + +struct Test { int a; }; +using AlignedTest = __declspec(align(16)) const Test; +static_assert(alignof(AlignedTest) == 16, "error"); \ No newline at end of file