[PATCH] Use the MS ABI for Win32 target by default

Richard Smith richard at metafoo.co.uk
Fri Dec 13 15:23:50 PST 2013



================
Comment at: test/CXX/drs/dr2xx.cpp:543
@@ -542,3 +542,3 @@
   struct C : A, B {
-    virtual ~C();
+    virtual ~C(); // expected-error 0-1 {{'operator delete' found in multiple base classes}}
   };
----------------
Hans Wennborg wrote:
> Hans Wennborg wrote:
> > Richard Smith wrote:
> > > Reid Kleckner wrote:
> > > > So, I remember we decided to do it this way, but now we've essentially weakened this test to pass if we fail to diagnose this in the Itanium C++ ABI.  Can you remind me what the issue is here?  This has to do with differing operator delete lookup behavior?
> > > Please conditionalize this extra diagnostic on use of the MS ABI. Do we have a predefined macro indicating the ABI? If not, maybe we should add one?
> > > Can you remind me what the issue is here? This has to do with differing operator delete lookup behavior?
> > 
> > Yes, we diagnose the multiple 'operator delete' when 'virtual ~C()' is declared below, whereas in Itanium we diagnose it when that dtor is defined further on.
> > Please conditionalize this extra diagnostic on use of the MS ABI.
> Done.
> 
> >Do we have a predefined macro indicating the ABI? If not, maybe we should add one?
> No, we don't have a macro for this. We could create one, but it's also easy to run the test in both modes and set a macro ourselves, I've done that in a few other tests.
I think the macro would be generally useful, and not just as a way of cleaning up these tests slightly. But that's something we can address separately.

================
Comment at: test/CXX/class.access/p4.cpp:129
@@ -123,1 +128,3 @@
+#endif
+  void foo(A param) { // Okay in Itanium.
     A local; // expected-error {{variable of type 'test3::A' has private destructor}}
----------------
Hans Wennborg wrote:
> Richard Smith wrote:
> > Why do we do the access check in the callee under the MS ABI? We can still do dtor access checks in the caller, even though we actually make the call in the callee, can't we? Presumably MSVC redundantly checks access in both places?
> > 
> > (Do we need to omit the access checking in the caller for compatibility somehow?)
> IIRC, Reid told me that John had told him to do the access check in the callee too when he implemented this.
> 
> We still have the access check in the caller.
So the access check in the callee serves no purpose other than to reject valid code? Can we just remove it?

================
Comment at: test/CXX/special/class.dtor/p5-0x.cpp:98-104
@@ -96,2 +97,9 @@
 } d2; // expected-error {{deleted function}}
+#ifdef MSABI
+// expected-error at +7 {{no suitable member 'operator delete' in 'D3'}}
+// expected-note at +7 {{member 'operator delete' declared here}}
+// expected-note at +7 {{member 'operator delete' declared here}}
+// expected-error at +9 {{attempt to use a deleted function}}
+// expected-note at +9 {{function has been explicitly marked deleted here}}
+#endif
 struct D3 { // expected-note {{virtual destructor requires an unambiguous, accessible 'operator delete'}}
----------------
Hans Wennborg wrote:
> Richard Smith wrote:
> > This looks incorrect. We shouldn't be trying to mark the `operator delete` as used if the destructor is deleted.
> But neither ~D3() nor ~D4() below are deleted.
The expected-* diagnostics below say that they both are.

================
Comment at: test/Sema/empty1.c:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify -Wc++-compat
+// RUN: %clang_cc1 %s -cxx-abi itanium -fsyntax-only -verify -Wc++-compat
 
----------------
Hans Wennborg wrote:
> Richard Smith wrote:
> > This looks weird. I think you're adding this because empty structs have size 4 under MSVC, but that's controlled by the psABI, not the C++ ABI.
> Hmm, it seems to be controlled by -cxx-abi by us :) I agree this is weird, though.
> 
> Would you be ok a FIXME here and filing a bug with Warren on the cc list? Or running the test with a fixed target?
Sure, a FIXME works for me.

================
Comment at: test/SemaCXX/destructor.cpp:108-117
@@ -102,6 +107,12 @@
 
+#ifdef MSABI
+    // expected-note at +2 {{in instantiation of member function 'test6::A<int>::operator delete' requested here}}
+#endif
     virtual ~A() {}
   };
 
-  class B : A<int> { B(); }; // expected-note {{in instantiation of member function 'test6::A<int>::operator delete' requested here}}
+#ifndef MSABI
+    // expected-note at +2 {{in instantiation of member function 'test6::A<int>::operator delete' requested here}}
+#endif
+  class B : A<int> { B(); };
   B::B() {}
----------------
Hans Wennborg wrote:
> Richard Smith wrote:
> > There's something odd here. We should be producing a note indicating the place at which the instantiation of `A<int>` was triggered under the MS ABI.
> But we are. In MS ABI we emit a note on the declaration of '~A()'. On itanium the note comes later, on the definition of 'class B'.
Sure, but that diagnostic doesn't actually say why we're instantiating `A<int>`; we're missing the outermost level of the instantiation backtrace.

================
Comment at: test/SemaCXX/implicit-virtual-member-functions.cpp:7-16
@@ -5,10 +6,12 @@
 
+#ifndef MSABI
 struct B : A { // expected-error {{no suitable member 'operator delete' in 'B'}}
   virtual void f();
 
   void operator delete (void *, int); // expected-note {{'operator delete' declared here}}
 };
 
 void B::f() { // expected-note {{implicit destructor for 'B' first required here}}
 }
+#endif
 
----------------
Hans Wennborg wrote:
> Richard Smith wrote:
> > Can you provide an alternative set of expected diagnostics here for MS ABI rather than disabling that half of the test? (I assume the point is that we trigger `operator delete` lookup earlier?)
> In MS ABI we don't require the destructor for B here, so we expect no diagnostics. I've fixed the test to check that.
That seems inconsistent: `B` (implicitly) has a virtual destructor, and `operator delete` lookup for it would fail, but we don't diagnose it.

================
Comment at: test/SemaCXX/virtual-base-used.cpp:1
@@ -1,2 +1,2 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -cxx-abi itanium -verify %s
 // PR7800
----------------
Hans Wennborg wrote:
> Richard Smith wrote:
> > Why does this test need to force the Itanium ABI?
> In MS ABI we don't emit any diagnostics in this test. We should probably take a second look and verify that's correct behaviour.
> 
> I figured the test mostly seemed to be a regression test for the ICE in PR7800, so maybe we shouldn't run it in MS mode since none of the expectations apply.
This looks like the same root cause as `implicit-virtual-member-functions.cpp` -- we don't trigger vtable emission, so we don't implicitly define the destructor. In both that file and this one, you could get more consistent behavior in the MS ABI with something like this:

    void D::foo() {}
    D d;
  #if MSABI
    // expected-note at -2 {{implicit destructor for 'B' first required here}}
  #else
    // expected-note at -5 {{implicit destructor for 'B' first required here}}
  #endif

================
Comment at: test/SemaCXX/undefined-internal.cpp:1-4
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -cxx-abi itanium -fsyntax-only -verify %s
 
 // Make sure we don't produce invalid IR.
-// RUN: %clang_cc1 -emit-llvm-only %s
+// RUN: %clang_cc1 -cxx-abi itanium -emit-llvm-only %s
 
----------------
Hans Wennborg wrote:
> Richard Smith wrote:
> > Why does this test need to force the Itanium ABI?
> We fail during codegen with "error: cannot mangle RTTI descriptors for type 'A' yet", and we need RTTI for the typeid which is used in the test.
> 
> This isn't a problem for the '-verify' line though. I'll update that.
Please either XFAIL or add a FIXME; this test *should* pass without the -cxx-abi itanium.


http://llvm-reviews.chandlerc.com/D2401



More information about the cfe-commits mailing list