This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ObjC++: fix testcase failures on Darwin


This patch fixes the 5 @try/@catch ObjC++ testsuite failures on Darwin (Apple) with the NeXT runtime.

The problem is with the artificially volatilized types that are used when
setjmp/longjmp ObjC exception handling is being used (this currently happens
only on Darwin with the NeXT runtime).

The code we "inherited" from Apple flagged these artificially volatilized types
using an attribute ("objc_volatilized") but the problem is that newer GCCs are
smarted and consider attributes when building variants of types.  So the 
additional attribute actually confuses the type system (for example, if you start 
with a non-volatilized 'int' type, and build the artificially volatilized variant,
and then you try to get a non-volatile type variant using build_qualified_type(), 
you don't get the original type but a new 'int' type which preserves your new 
objc_volatilized attribute.  This new 'int' is identical to the normal 'int' 
though, except for the 'objc_volatilized' attribute, but has a different 
canonical type.  The C++ frontend detects this inconsistency and aborts).

So, in the end I created a new TYPE_ARTIFICIALLY_VOLATILIZED() flag that can 
be used for types (I used the base.side_effects flag which is unused for types 
in C/ObjC/C++/ObjC++), and used it to mark our artificially volatilized types.

Then the type system works again and everything seems to work with the next 
runtime, with the exception of two warnings in try-catch-12.m.  These occur when 
a real 'volatile' variable is encountered in the same context as artificially
volatilized ones, and if certain conditions are met the two types can get confused
and some warnings for the real volatile variable may not be produced.  To fix 
this, either we think of a completely different way of doing everything, or we 
may need to push some (or a lot of) awareness of TYPE_ARTIFICIALLY_VOLATILIZED() 
into tree.c.  This should be a separate patch; in the meanwhile I'd suggest
we xfail the test and open a PR so we don't forget about the problem.

Anyway, all in all we're down from 5 hard compilation failures to 2 missed minor warnings (for unusual cases), which seems a good improvement.

Ok to commit ?

Thanks

In gcc/:
2010-11-29  Nicola Pero  <nicola.pero@meta-innovation.com>

        * tree.h (TYPE_ARTIFICIALLY_VOLATILIZED): New.

In gcc/objc/:
2010-11-29  Nicola Pero  <nicola.pero@meta-innovation.com>

        * objc-act.c (objc_get_volatilized_type): New.
        (objc_get_non_volatilized_type): New.
        (objc_build_volatilized_type): Use objc_get_volatilized_type.
        Duplicate ObjC type information when building the volatilized
        type.  Set TYPE_ARTIFICIALLY_VOLATILIZED for the new type.
        (objc_non_volatilized_type): Use objc_get_non_volatilized_type.

Attachment: patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]