diff options
author | Joseph Myers <joseph@codesourcery.com> | 2011-08-19 14:25:51 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2011-08-19 14:25:51 +0100 |
commit | c4b3a0a0b9566dcd63e4a35ddcafa4b93055aa96 (patch) | |
tree | c6c54b66903cafd5d960e932fa497941dd2ad58a /gcc | |
parent | c26dffff5c573aa7f3935dddc8300a2c8fd660a1 (diff) | |
download | gcc-c4b3a0a0b9566dcd63e4a35ddcafa4b93055aa96.zip gcc-c4b3a0a0b9566dcd63e4a35ddcafa4b93055aa96.tar.gz gcc-c4b3a0a0b9566dcd63e4a35ddcafa4b93055aa96.tar.bz2 |
c-decl.c (grokdeclarator): Diagnose _Noreturn for non-C1X if pedantic.
* c-decl.c (grokdeclarator): Diagnose _Noreturn for non-C1X if
pedantic.
* c-parser.c (c_parser_declspecs): Include _Noreturn in syntax
comment.
* ginclude/stdnoreturn.h (noreturn): Don't define for C++.
testsuite:
* gcc.dg/c90-noreturn-1.c, gcc.dg/c99-noreturn-1.c: New tests.
From-SVN: r177899
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-decl.c | 13 | ||||
-rw-r--r-- | gcc/c-parser.c | 3 | ||||
-rw-r--r-- | gcc/ginclude/stdnoreturn.h | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c90-noreturn-1.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c99-noreturn-1.c | 5 |
7 files changed, 41 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index be47b95..9a8d24f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2011-08-19 Joseph Myers <joseph@codesourcery.com> + * c-decl.c (grokdeclarator): Diagnose _Noreturn for non-C1X if + pedantic. + * c-parser.c (c_parser_declspecs): Include _Noreturn in syntax + comment. + * ginclude/stdnoreturn.h (noreturn): Don't define for C++. + +2011-08-19 Joseph Myers <joseph@codesourcery.com> + * opth-gen.awk: Do not declare target save/restore structures and functions if IN_RTS defined. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index d824e12..d683d4e 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5986,7 +5986,18 @@ grokdeclarator (const struct c_declarator *declarator, /* Record that the function is declared `inline'. */ DECL_DECLARED_INLINE_P (decl) = 1; if (declspecs->noreturn_p) - TREE_THIS_VOLATILE (decl) = 1; + { + if (!flag_isoc1x) + { + if (flag_isoc99) + pedwarn (loc, OPT_pedantic, + "ISO C99 does not support %<_Noreturn%>"); + else + pedwarn (loc, OPT_pedantic, + "ISO C90 does not support %<_Noreturn%>"); + } + TREE_THIS_VOLATILE (decl) = 1; + } } } else diff --git a/gcc/c-parser.c b/gcc/c-parser.c index d0f8fba..8d7bb99 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -1905,6 +1905,9 @@ c_parser_static_assert_declaration_no_semi (c_parser *parser) C99 6.7.4: function-specifier: inline + _Noreturn + + (_Noreturn is new in C1X.) C90 6.5.2, C99 6.7.2: type-specifier: diff --git a/gcc/ginclude/stdnoreturn.h b/gcc/ginclude/stdnoreturn.h index c92537c..3efbd8a 100644 --- a/gcc/ginclude/stdnoreturn.h +++ b/gcc/ginclude/stdnoreturn.h @@ -26,6 +26,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifndef _STDNORETURN_H #define _STDNORETURN_H +#ifndef __cplusplus + #define noreturn _Noreturn +#endif + #endif /* stdnoreturn.h */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8d26536..23b70e8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-08-19 Joseph Myers <joseph@codesourcery.com> + + * gcc.dg/c90-noreturn-1.c, gcc.dg/c99-noreturn-1.c: New tests. + 2011-08-19 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * gcc.dg/builtins-67.c: Use dg-add-options c99_runtime. diff --git a/gcc/testsuite/gcc.dg/c90-noreturn-1.c b/gcc/testsuite/gcc.dg/c90-noreturn-1.c new file mode 100644 index 0000000..87b832e --- /dev/null +++ b/gcc/testsuite/gcc.dg/c90-noreturn-1.c @@ -0,0 +1,5 @@ +/* Test _Noreturn not in C90. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */ + +_Noreturn void f (void); /* { dg-error "ISO C90 does not support '_Noreturn'" } */ diff --git a/gcc/testsuite/gcc.dg/c99-noreturn-1.c b/gcc/testsuite/gcc.dg/c99-noreturn-1.c new file mode 100644 index 0000000..4cbc513 --- /dev/null +++ b/gcc/testsuite/gcc.dg/c99-noreturn-1.c @@ -0,0 +1,5 @@ +/* Test _Noreturn not in C99. */ +/* { dg-do compile } */ +/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */ + +_Noreturn void f (void); /* { dg-error "ISO C99 does not support '_Noreturn'" } */ |