diff options
author | Joseph Myers <joseph@codesourcery.com> | 2009-04-25 19:55:50 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2009-04-25 19:55:50 +0100 |
commit | 92f6fd0b80bedd1ed200c687f2c9f82e1c09cd1a (patch) | |
tree | 37e3ee9a7eeffd28c6d57a7ad6c934131c358b1b /gcc/c-decl.c | |
parent | f88d07724fad4b84d8e73ff30b6f3c16cd832ef3 (diff) | |
download | gcc-92f6fd0b80bedd1ed200c687f2c9f82e1c09cd1a.zip gcc-92f6fd0b80bedd1ed200c687f2c9f82e1c09cd1a.tar.gz gcc-92f6fd0b80bedd1ed200c687f2c9f82e1c09cd1a.tar.bz2 |
re PR c/39564 (variably modified function return types not always diagnosed)
PR c/39564
* c-decl.c (grokdeclarator): Diagnose declarations of functions
with variably modified return type and no storage class
specifiers, except for the case of nested functions. Distinguish
extern declarations of functions with variably modified return
types from those of objects with variably modified types.
testsuite:
* gcc.dg/vla-19.c: New test.
From-SVN: r146778
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index d2dbfbe..9693a34 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -5012,11 +5012,17 @@ grokdeclarator (const struct c_declarator *declarator, DECL_TLS_MODEL (decl) = decl_default_tls_model (decl); } - if (storage_class == csc_extern + if ((storage_class == csc_extern + || (storage_class == csc_none + && TREE_CODE (type) == FUNCTION_TYPE + && !funcdef_flag)) && variably_modified_type_p (type, NULL_TREE)) { /* C99 6.7.5.2p2 */ - error ("object with variably modified type must have no linkage"); + if (TREE_CODE (type) == FUNCTION_TYPE) + error ("non-nested function with variably modified type"); + else + error ("object with variably modified type must have no linkage"); } /* Record `register' declaration for warnings on & |