[cfe-commits] r150128 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaCXX/function-extern-c.cpp

Aaron Ballman aaron at aaronballman.com
Thu Feb 9 15:18:12 PST 2012


On Thu, Feb 9, 2012 at 5:04 PM, Chandler Carruth <chandlerc at google.com> wrote:
> On Thu, Feb 9, 2012 at 12:42 PM, Matt Beaumont-Gay <matthewbg at google.com>
> wrote:
>>
>> On a different note, what do you think about not warning when the
>> return type is incomplete? It's a little surprising that we warn on
>> this:
>>
>> struct foo;
>> extern "C" { struct foo get_foo(void); }
>> struct foo { };
>
>
> I think that's a bug. Incomplete struct types are relatively common as
> "opaque" return types.

Oddly enough, MSVC does complain on that code.

error C2526: 'get_foo' : C linkage function cannot return C++ class 'foo'

It's hard to really say one way or the other, since you can make a
case either way.  Yes, it may be perfectly fine as an opaque type, but
it may also contain non-C-compatible fields which would justify the
warning.

~Aaron



More information about the cfe-commits mailing list