Hi,

On Fri, Jul 01, 2011 at 09:31:30AM -0700, Delesley Hutchins wrote:
> > Just out of curiosity, I does your
> > analysis crash also on the testcase below (add the Mutex field if it
> > is necessary)?
> 
> No, the static type of b (in b->test()) remains Bar* in gimple, so the
> analysis works fine (i.e. the analyzer will not crash).
> 

Sorry, I've had a look only just now and you do the analysis before
early inlining and as long as you do that, the type is really Bar and
you are fine as far as far as placement new is concerned.

However, on the second thought, I still think you need to handle the
case when BINFO_VIRTUALS are NULL in cp_get_virtual_function_decl
(BTW, there is a non-langhook variant in gimple-fold.c called
gimple_get_virt_method_for_binfo) because of the case below.

Martin


// { dg-do compile }
// { dg-options "-Wthread-safety -O" }
//#include "thread_annot_common.h"

class Anc {
public:
  int a;
};

class Foo : public Anc {
public:
  //  Mutex m;

  Foo();
  virtual ~Foo();
  virtual void doSomething() = 0;// EXCLUSIVE_LOCKS_REQUIRED(m) = 0;
};


class FooDerived : public Foo {
public:
  FooDerived();
  virtual ~FooDerived();
  virtual void doSomething();
};

// reinterpret_cast
void foo1(Anc* ptr)
{
  reinterpret_cast<Foo*>(ptr)->doSomething();
}

// C-style cast
void foo2(Anc* buf)
{
  ((Foo*) buf)->doSomething();
}


Reply via email to