[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-commits
Subject:    [PATCH] ignore __declspec(novtable) on non-Windows platforms
From:       Bob Wilson <bob.wilson () apple ! com>
Date:       2015-07-17 0:42:06
Message-ID: 2B4B8370-4524-45BB-BE9E-344EA4D4EBA8 () apple ! com
[Download RAW message or body]

Clang used to silently ignore __declspec(novtable) for all platforms, but it is now \
implemented for Windows. However, we don't check if the target is Windows. This does \
not work when using the Itanium ABI, where the class layout for complex class \
hierarchies is stored in the vtable. Leaving the vtable uninitialized on non-Windows \
platforms does not work in that case. It might be possible to honor the novtable \
attribute in some simple cases and either report an error or ignore it in more \
complex situations, but it's not clear if that would be worthwhile. There is also \
value in having a simple and predictable behavior, so I am proposed the attached \
patch which simply ignores novtable on non-Windows platforms.


["novtable.patch" (novtable.patch)]

diff --git include/clang/Basic/Attr.td include/clang/Basic/Attr.td
index fb1eb58..43ce353 100644
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1814,7 +1814,7 @@ def TypeTagForDatatype : InheritableAttr {
 
 // Microsoft-related attributes
 
-def MSNoVTable : InheritableAttr {
+def MSNoVTable : InheritableAttr, TargetSpecificAttr<TargetWindows> {
   let Spellings = [Declspec<"novtable">];
   let Subjects = SubjectList<[CXXRecord]>;
   let Documentation = [MSNoVTableDocs];
diff --git test/SemaCXX/ms-novtable.cpp test/SemaCXX/ms-novtable.cpp
index 2d55c48..31975b3 100644
--- test/SemaCXX/ms-novtable.cpp
+++ test/SemaCXX/ms-novtable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-extensions -Wno-microsoft \
-std=c++11 +// RUN: %clang_cc1 -triple i386-pc-win32 %s -fsyntax-only -verify \
-fms-extensions -Wno-microsoft -std=c++11  
 struct __declspec(novtable) S {};
 enum __declspec(novtable) E {}; // expected-warning{{'novtable' attribute only \
                applies to classes}}
diff --git test/SemaCXX/ms-unsupported.cpp test/SemaCXX/ms-unsupported.cpp
new file mode 100644
index 0000000..4ad398f
--- /dev/null
+++ test/SemaCXX/ms-unsupported.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-apple-osx %s -fsyntax-only -verify -fms-extensions \
-Wno-microsoft -std=c++11 +
+// The __declspec(novtable) attribute is ignored except on Windows.
+struct __declspec(novtable) S {}; // expected-warning{{__declspec attribute \
'novtable' is not supported}}



_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic