blob: 047cdad6b5a0a915e7139eb645d421b87c473c2a [file] [log] [blame]
Mike Stumpedd722e2009-12-15 18:02:45 +00001// RUN: clang -cc1 -verify -fsyntax-only %s
Daniel Dunbard3f2c102008-10-19 02:04:16 +00002
3static void (*fp0)(void) __attribute__((noreturn));
4
5static void __attribute__((noreturn)) f0(void) {
6 fatal();
Mike Stump29813c32009-09-16 00:39:34 +00007} // expected-warning {{function declared 'noreturn' should not return}}
Daniel Dunbard3f2c102008-10-19 02:04:16 +00008
9// On K&R
10int f1() __attribute__((noreturn));
11
12int g0 __attribute__((noreturn)); // expected-warning {{'noreturn' attribute only applies to function types}}
13
14int f2() __attribute__((noreturn(1, 2))); // expected-error {{attribute requires 0 argument(s)}}
Mike Stumpf7c41da2009-04-29 00:43:21 +000015
16void f3() __attribute__((noreturn));
Mike Stumpf7c41da2009-04-29 00:43:21 +000017void f3() {
Douglas Gregor9dc9c372009-10-21 15:46:01 +000018 return; // expected-warning {{function 'f3' declared 'noreturn' should not return}}
Mike Stumpf7c41da2009-04-29 00:43:21 +000019}
20
Douglas Gregor9dc9c372009-10-21 15:46:01 +000021#pragma clang diagnostic error "-Winvalid-noreturn"
Chris Lattner86625872009-05-31 19:32:13 +000022
23void f4() __attribute__((noreturn));
24void f4() {
Douglas Gregor9dc9c372009-10-21 15:46:01 +000025 return; // expected-error {{function 'f4' declared 'noreturn' should not return}}
Chris Lattner86625872009-05-31 19:32:13 +000026}
27
Douglas Gregor47259d92009-08-05 19:03:35 +000028// PR4685
29extern void f5 (unsigned long) __attribute__ ((__noreturn__));
30
31void
32f5 (unsigned long size)
33{
34
Mike Stump29813c32009-09-16 00:39:34 +000035}
Mike Stumpedd722e2009-12-15 18:02:45 +000036
37// PR2461
38__attribute__((noreturn)) void f(__attribute__((noreturn)) void (*x)(void)) {
39 x();
40}