Bug 39564 - variably modified function return types not always diagnosed
Summary: variably modified function return types not always diagnosed
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks: 16989
  Show dependency treegraph
 
Reported: 2009-03-26 17:41 UTC by Joseph S. Myers
Modified: 2009-04-25 18:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.5.0
Known to fail:
Last reconfirmed: 2009-03-30 01:10:16


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2009-03-26 17:41:43 UTC
Block-scope ordinary identifiers with variably modified type are required
to have no linkage.  Block-scope function declarations implicitly have
external linkage.  However, GCC diagnoses such declarations with variably
modified type only with an explicit "extern".

The code

int a;
void
f (void)
{
  typedef int T[a];
  extern T *g (void);
}

is correctly diagnosed with -std=c99 -pedantic-errors, although the error
message "object with variably modified type must have no linkage" is
bad (it's a function, not an object).  The equivalent code

int a;
void
f (void)
{
  typedef int T[a];
  T *g (void);
}

should be diagnosed, but is not.
Comment 1 Joseph S. Myers 2009-04-25 18:56:06 UTC
Subject: Bug 39564

Author: jsm28
Date: Sat Apr 25 18:55:50 2009
New Revision: 146778

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146778
Log:
	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.

Added:
    trunk/gcc/testsuite/gcc.dg/vla-19.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 2 Joseph S. Myers 2009-04-25 18:56:59 UTC
Fixed for 4.5.