[cfe-commits] r102464 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Sema/attr-regparm.c

Eli Friedman eli.friedman at gmail.com
Wed Apr 28 13:51:50 PDT 2010


On Wed, Apr 28, 2010 at 9:45 AM, Abramo Bagnara
<abramo.bagnara at gmail.com> wrote:
> Il 28/04/2010 18:15, Daniel Dunbar ha scritto:
>> Hi Eli,
>>
>> I am about to revert this, it breaks a lot of project builds. I don't
>> have a test case handy, but they all seem to involve noreturn. This is
>> the ClamAV failure, for example:
>> --
>> clamdtop.c:435:24: error: conflicting types for 'exit_program'
>> static void __noreturn exit_program(enum exit_reason reason, const
>> char *func, unsigned line)
>>                        ^
>> clamdtop.c:113:13: note: previous declaration is here
>> static void exit_program(enum exit_reason reason, const char *func,
>> unsigned line);
>>             ^
>
> In added testcase:
>
> __attribute((regparm(1))) int g(void);
> __attribute((regparm(2))) int g(void);
>
> we have conflicting attributes, while in
>
> enum exit_reason;
>
> #define __noreturn __attribute__((noreturn))
> static void exit_program(enum exit_reason reason, const char *func,
>                         unsigned line);
> static void __noreturn exit_program(enum exit_reason reason, const
>                                    char *func, unsigned line)
>
> we should merge the attributes of the two function declarations.
>
> That apart, the patch concerning type incompatibility is correct.

No, I think the issue is that the gcc model is seriously messed up.
Take the following testcase:

void a();
void b() __attribute((noreturn));
typedef void (*f1)();
typedef void (*f2)() __attribute__ ((noreturn));

int c() {
  return __builtin_types_compatible_p(typeof(a),typeof(b));
}

int p() {
  return __builtin_types_compatible_p(f1, f2);
}

You would think c() and p() would return the same thing, but they don't.

I do not look forward to modeling this in clang...

-Eli




More information about the cfe-commits mailing list