From 7eca8a3d41eef5facf3847c33ce1e6b1e35bc7c8 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 23 May 2016 17:32:35 +0000 Subject: [PATCH] Address post-commit review feedback to r270457 Add two tests which show our error handling behavior for invalid parameters in the layout_version and empty_bases attributes. Amend our documentation to make it more clear that __declspec(empty_bases) and __declspec(layout_version) can only apply to classes, structs, and unions. llvm-svn: 270461 --- clang/include/clang/Basic/AttrDocs.td | 2 ++ clang/test/SemaCXX/ms-empty_bases.cpp | 2 ++ clang/test/SemaCXX/ms-layout_version.cpp | 1 + 3 files changed, 5 insertions(+) diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index e1c551648d4e..3f19772517eb 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -1558,6 +1558,7 @@ def EmptyBasesDocs : Documentation { let Content = [{ The empty_bases attribute permits the compiler to utilize the empty-base-optimization more frequently. +This attribute only applies to struct, class, and union types. It is only supported when using the Microsoft C++ ABI. }]; } @@ -1567,6 +1568,7 @@ def LayoutVersionDocs : Documentation { let Content = [{ The layout_version attribute requests that the compiler utilize the class layout rules of a particular compiler version. +This attribute only applies to struct, class, and union types. It is only supported when using the Microsoft C++ ABI. }]; } diff --git a/clang/test/SemaCXX/ms-empty_bases.cpp b/clang/test/SemaCXX/ms-empty_bases.cpp index 4452d558711e..69d9e2799b8f 100644 --- a/clang/test/SemaCXX/ms-empty_bases.cpp +++ b/clang/test/SemaCXX/ms-empty_bases.cpp @@ -5,3 +5,5 @@ enum __declspec(empty_bases) E {}; // expected-warning{{'empty_bases' attribute int __declspec(empty_bases) I; // expected-warning{{'empty_bases' attribute only applies to classes}} typedef struct T __declspec(empty_bases) U; // expected-warning{{'empty_bases' attribute only applies to classes}} auto z = []() __declspec(empty_bases) { return nullptr; }; // expected-warning{{'empty_bases' attribute only applies to classes}} + +struct __declspec(empty_bases(1)) X {}; // expected-error{{'empty_bases' attribute takes no arguments}} diff --git a/clang/test/SemaCXX/ms-layout_version.cpp b/clang/test/SemaCXX/ms-layout_version.cpp index b8a10341f23a..7f83b2d4473e 100644 --- a/clang/test/SemaCXX/ms-layout_version.cpp +++ b/clang/test/SemaCXX/ms-layout_version.cpp @@ -8,3 +8,4 @@ auto z = []() __declspec(layout_version(19)) { return nullptr; }; // expected-wa struct __declspec(layout_version(18)) X {}; // expected-error{{'layout_version' attribute parameter 18 is out of bounds}} struct __declspec(layout_version(20)) Y {}; // expected-error{{'layout_version' attribute parameter 20 is out of bounds}} +struct __declspec(layout_version) Z {}; // expected-error{{attribute takes one argument}}