This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Two C regressions in GCC 3.4.


This patch fixes two regressions in C conformance for GCC 3.4 found by
running testsuites.

The first has to do with block-scope "extern" declarations for the
same identifier already declared as "static" in the global scope.  I
added code to issue an error about that a while back, but it's too
aggressive; that's only invalid if there's an intervening declaration
that makes the outer declaration invisible.

The second problem has to do with VLAs; something like:

+   typedef int T[n++];

caused DWARF2 to fall over.  I've not tried to express this in DWARF,
but I've kept the compiler from falling over.

Tested on i686-pc-linux-gnu, applied on the mainline and the 3.4
branch.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-03-18  Mark Mitchell  <mark@codesourcery.com>

	* c-decl.c (grokdeclarator): Do not complain about redeclaring
	visible "static" identifiers "extern" in a local scope.

	* dwarf2out.c (loc_descriptor_from_tree): Handle pre- and
	post-increments/decrements.

2004-03-18  Mark Mitchell  <mark@codesourcery.com>

	* gcc.dg/local1.c: New test.

	* gcc.dg/debug/dwarf2/c99-typedef1.c: New test.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.470.4.10
diff -c -5 -p -r1.470.4.10 c-decl.c
*** c-decl.c	13 Mar 2004 19:05:46 -0000	1.470.4.10
--- c-decl.c	18 Mar 2004 17:51:50 -0000
*************** grokdeclarator (tree declarator, tree de
*** 4414,4431 ****
  	else if (type_quals)
  	  type = c_build_qualified_type (type, type_quals);
  
  	/* It is invalid to create an `extern' declaration for a
  	   variable if there is a global declaration that is
! 	   `static'.  */
  	if (extern_ref && current_scope != global_scope)
  	  {
  	    tree global_decl;
  
  	    global_decl = identifier_global_value (declarator);
  	    if (global_decl
  		&& TREE_CODE (global_decl) == VAR_DECL
  		&& !TREE_PUBLIC (global_decl))
  	      error ("variable previously declared `static' redeclared "
  		     "`extern'");
  	  }
  
--- 4414,4432 ----
  	else if (type_quals)
  	  type = c_build_qualified_type (type, type_quals);
  
  	/* It is invalid to create an `extern' declaration for a
  	   variable if there is a global declaration that is
! 	   `static' and the global declaration is not visible.  */
  	if (extern_ref && current_scope != global_scope)
  	  {
  	    tree global_decl;
  
  	    global_decl = identifier_global_value (declarator);
  	    if (global_decl
  		&& TREE_CODE (global_decl) == VAR_DECL
+ 		&& lookup_name (declarator) != global_decl
  		&& !TREE_PUBLIC (global_decl))
  	      error ("variable previously declared `static' redeclared "
  		     "`extern'");
  	  }
  
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.478.2.7
diff -c -5 -p -r1.478.2.7 dwarf2out.c
*** dwarf2out.c	9 Mar 2004 02:01:07 -0000	1.478.2.7
--- dwarf2out.c	18 Mar 2004 17:51:51 -0000
*************** loc_descriptor_from_tree (tree loc, int 
*** 8504,8513 ****
--- 8504,8520 ----
        return 0;
  
      case CALL_EXPR:
        return 0;
  
+     case PREINCREMENT_EXPR:
+     case PREDECREMENT_EXPR:
+     case POSTINCREMENT_EXPR:
+     case POSTDECREMENT_EXPR:
+       /* There are no opcodes for these operations.  */
+       return 0;
+ 
      case ADDR_EXPR:
        /* We can support this only if we can look through conversions and
  	 find an INDIRECT_EXPR.  */
        for (loc = TREE_OPERAND (loc, 0);
  	   TREE_CODE (loc) == CONVERT_EXPR || TREE_CODE (loc) == NOP_EXPR
Index: testsuite/gcc.dg/local1.c
===================================================================
RCS file: testsuite/gcc.dg/local1.c
diff -N testsuite/gcc.dg/local1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/local1.c	18 Mar 2004 17:51:57 -0000
***************
*** 0 ****
--- 1,7 ----
+ static int i;
+ 
+ extern int i;
+ 
+ static void f() {
+   extern int i;
+ }
Index: testsuite/gcc.dg/debug/dwarf2/c99-typedef1.c
===================================================================
RCS file: testsuite/gcc.dg/debug/dwarf2/c99-typedef1.c
diff -N testsuite/gcc.dg/debug/dwarf2/c99-typedef1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/debug/dwarf2/c99-typedef1.c	18 Mar 2004 17:51:58 -0000
***************
*** 0 ****
--- 1,9 ----
+ // { dg-options "-std=iso9899:1999 -gdwarf-2" }
+ 
+ void f() {
+   int n = 3;
+   typedef int T[n++];
+   
+   T t;
+   t[0] = 7;
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]