2009-12-15 23:14:24 +03:00
|
|
|
// RUN: %clang_cc1 -verify -fsyntax-only %s
|
2008-10-19 06:04:16 +04:00
|
|
|
|
|
|
|
static void (*fp0)(void) __attribute__((noreturn));
|
|
|
|
|
2010-01-09 23:43:19 +03:00
|
|
|
void fatal();
|
|
|
|
|
2008-10-19 06:04:16 +04:00
|
|
|
static void __attribute__((noreturn)) f0(void) {
|
|
|
|
fatal();
|
2009-09-16 04:39:34 +04:00
|
|
|
} // expected-warning {{function declared 'noreturn' should not return}}
|
2008-10-19 06:04:16 +04:00
|
|
|
|
|
|
|
// On K&R
|
2010-09-03 04:25:02 +04:00
|
|
|
int f1() __attribute__((noreturn));
|
2008-10-19 06:04:16 +04:00
|
|
|
|
2010-02-06 00:31:56 +03:00
|
|
|
int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' only applies to function types; type here is 'int'}}
|
2008-10-19 06:04:16 +04:00
|
|
|
|
2011-03-02 15:15:05 +03:00
|
|
|
int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute takes no arguments}}
|
2009-04-29 04:43:21 +04:00
|
|
|
|
|
|
|
void f3() __attribute__((noreturn));
|
|
|
|
void f3() {
|
2009-10-21 19:46:01 +04:00
|
|
|
return; // expected-warning {{function 'f3' declared 'noreturn' should not return}}
|
2009-04-29 04:43:21 +04:00
|
|
|
}
|
|
|
|
|
2009-10-21 19:46:01 +04:00
|
|
|
#pragma clang diagnostic error "-Winvalid-noreturn"
|
2009-05-31 23:32:13 +04:00
|
|
|
|
|
|
|
void f4() __attribute__((noreturn));
|
|
|
|
void f4() {
|
2009-10-21 19:46:01 +04:00
|
|
|
return; // expected-error {{function 'f4' declared 'noreturn' should not return}}
|
2009-05-31 23:32:13 +04:00
|
|
|
}
|
|
|
|
|
2009-08-05 23:03:35 +04:00
|
|
|
// PR4685
|
|
|
|
extern void f5 (unsigned long) __attribute__ ((__noreturn__));
|
|
|
|
|
|
|
|
void
|
|
|
|
f5 (unsigned long size)
|
|
|
|
{
|
|
|
|
|
2009-09-16 04:39:34 +04:00
|
|
|
}
|
2009-12-15 21:02:45 +03:00
|
|
|
|
|
|
|
// PR2461
|
|
|
|
__attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
|
|
|
|
x();
|
|
|
|
}
|
2010-04-30 13:13:03 +04:00
|
|
|
|
2011-03-02 15:15:05 +03:00
|
|
|
typedef void (*Fun)(void) __attribute__ ((noreturn(2))); // expected-error {{attribute takes no arguments}}
|