From cd18b4f7f464283a48c003075de1939c39486348 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Tue, 2 Aug 2022 20:07:43 +0200 Subject: [PATCH] Do not use noreturn in C99 mode on Solaris Sudio cc (re: c4f980eb) If the -xc99 or -std=c99 flag is passed to Solaris Studio cc, the build fails with a syntax error on the 'noreturn' keyword. That keyword was introduced in the C11 standard; C99 does not have it. The features/common test decides that we can use the 'noreturn' optimization if the header is present on the system, but that is not correct; standards flags may disable it. src/lib/libast/features/common: - Remove two unused tests for extern and void*, all part of C90 which we now require (re: a1f5c992). - Add test that checks for 'noreturn' by compiling a test program. - Use that test's result to decide whether to define 'noreturn' as empty or not. --- src/lib/libast/features/common | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/lib/libast/features/common b/src/lib/libast/features/common index c1cf64aec..81f603529 100644 --- a/src/lib/libast/features/common +++ b/src/lib/libast/features/common @@ -1,19 +1,16 @@ iff AST_COMMON -hdr pthread,stdarg,stddef,stdint,stdnoreturn,inttypes,types,unistd +hdr pthread,stdarg,stddef,stdint,inttypes,types,unistd sys types typ long.double,size_t,ssize_t typ __va_list stdio.h mac SF_APPEND,SF_CLOSE sys/stat.h sys/socket.h -std proto note{ standard C prototypes ok }end compile{ - extern int foo(int, int); - bar() { foo(1, 1); } -}end - -tst ptr_void note{ standard C void* ok }end compile{ - extern void* foo(); - void* bar() { return foo(); } +std noreturn note{ noreturn ok }end compile{ + #include + #include + noreturn void foo(void) { exit(0); } + int main(void) { foo(); } }end cat{ @@ -70,7 +67,7 @@ cat{ # endif #endif - #if !_hdr_stdnoreturn + #if !_std_noreturn #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)) #define noreturn __attribute__((noreturn)) #else @@ -78,7 +75,7 @@ cat{ #endif /* __GNUC__ */ #else #include - #endif /* _hdr_stdnoreturn */ + #endif /* _std_noreturn */ }end if tst - note{ + works }end compile{