Bug 25802 - VM types of external and internal linkage variables not diagnosed
Summary: VM types of external and internal linkage variables not diagnosed
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
: 29126 (view as bug list)
Depends on:
Blocks: 16989
  Show dependency treegraph
 
Reported: 2006-01-16 00:32 UTC by Joseph S. Myers
Modified: 2006-09-19 03:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-01-16 01:19:09


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2006-01-16 00:32:32 UTC
GCC doesn't diagnose function-scope VM declarations of variables with external or internal linkage.  (VM declarations of function-local statics are OK.)  Four tests (all should be rejected unconditionally, none are even with -std=c99 -pedantic-errors):

extern int (*a)[];
void f(int b) { extern int (*a)[b]; }

static int (*a)[];
void f(int b) { extern int (*a)[b]; }

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

static int (*a)[];
void f(int b) { typedef int (*T)[b]; extern T a; }
Comment 1 Andrew Pinski 2006-01-16 01:19:09 UTC
Confirmed.
Comment 2 Mike Stump 2006-05-06 21:24:46 UTC
I have a fix for this, will post.
Comment 3 mrs@gcc.gnu.org 2006-05-18 18:22:26 UTC
Subject: Bug 25802

Author: mrs
Date: Thu May 18 18:22:12 2006
New Revision: 113888

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113888
Log:
	Fix up vla, vm and [*] sematics.

	PR c/18740
	PR c/7948
	PR c/25802
	* c-tree.h (struct c_arg_info): Add had_vla_unspec.
	(c_vla_unspec_p): Add.
	(c_vla_type_p): Add.
	* c-decl.c (struct c_scope): Add had_vla_unspec.
	(build_array_declarator): Add support for [*].
	(grokdeclarator): Likewise.
	(grokparms): Likewise.
	(get_parm_info): Likewise.
	* c-objc-common.c (c_vla_unspec_p): Likewise.
	* c-objc-common.h (LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P): Likewise.
	* c-parser.c (c_parser_typeof_specifier): Evaluate arguments to
	typeof when argument is a variably modified type not inside sizeof or alignof.
	(c_parser_direct_declarator_inner): Propagate errors.
	(c_parser_sizeof_expression): Add support for [*].
	* c-typeck.c (c_vla_type_p): Add.
	(composite_type): Add support for vla compositing.
	(comptypes_internal): Add support for vla compatibility.
	(c_expr_sizeof_expr): Evaluate vla arguments.
	* tree.c (variably_modified_type_p): Update comment for [*].

testsuite:
	* gcc.dg/c90-arraydecl-1.c: Update for vla, vm [*] fixups.
	* gcc.dg/vla-4.c: Add.
	* gcc.dg/vla-5.c: Add.
	* gcc.dg/vla-6.c: Add.

Added:
    trunk/gcc/testsuite/gcc.dg/vla-4.c
    trunk/gcc/testsuite/gcc.dg/vla-5.c
    trunk/gcc/testsuite/gcc.dg/vla-6.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-decl.c
    trunk/gcc/c-objc-common.c
    trunk/gcc/c-objc-common.h
    trunk/gcc/c-parser.c
    trunk/gcc/c-tree.h
    trunk/gcc/c-typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/c90-arraydecl-1.c
    trunk/gcc/tree.c

Comment 4 Mike Stump 2006-05-18 19:29:36 UTC
aka radr://4336222
Comment 5 Joseph S. Myers 2006-06-04 17:03:00 UTC
Fixed for 4.2.
Comment 6 Andrew Pinski 2006-09-19 03:33:10 UTC
*** Bug 29126 has been marked as a duplicate of this bug. ***