[llvm-commits] CVS: llvm-gcc/gcc/c-typeck.c c-common.c

Chris Lattner lattner at cs.uiuc.edu
Mon Jan 3 14:13:31 PST 2005



Changes in directory llvm-gcc/gcc:

c-typeck.c updated: 1.4 -> 1.5
c-common.c updated: 1.5 -> 1.6
---
Log message:

Fix this more correctly, restoring our creation of a getelementptr for
pointer arithmetic.


---
Diffs of the changes:  (+8 -7)

Index: llvm-gcc/gcc/c-typeck.c
diff -u llvm-gcc/gcc/c-typeck.c:1.4 llvm-gcc/gcc/c-typeck.c:1.5
--- llvm-gcc/gcc/c-typeck.c:1.4	Sun Jan  2 22:17:21 2005
+++ llvm-gcc/gcc/c-typeck.c	Mon Jan  3 16:13:16 2005
@@ -46,8 +46,7 @@
 #include "target.h"
 #include "llvm-out.h"
 
-struct initializer_stack;
-extern struct initializer_stack *initializer_stack;
+extern int parsing_initializer;
 
 /* Nonzero if we've already printed a "missing braces around initializer"
    message within this initializer.  */
@@ -2418,7 +2417,7 @@
           /* DON'T fold this, unless its a constant expression which might 
            * initialize a global.
            */
-          if (!EMIT_LLVM || initializer_stack)
+          if (!EMIT_LLVM || parsing_initializer)
 	  return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0),
 				  TREE_OPERAND (arg, 1), 1);
 	}
@@ -2469,7 +2468,7 @@
 		return error_mark_node;
 	      }
 
-	    if (EMIT_LLVM && !initializer_stack) {
+	    if (EMIT_LLVM && !parsing_initializer) {
               /* For LLVM, don't fold pointer arithmetic unless doing so
                * produces a constant!
                */
@@ -4348,6 +4347,8 @@
   if (asmspec_tree)
     asmspec = TREE_STRING_POINTER (asmspec_tree);
 
+  ++parsing_initializer;
+
   p->decl = constructor_decl;
   p->asmspec = constructor_asmspec;
   p->require_constant_value = require_constant_value;
@@ -4430,6 +4431,7 @@
   constructor_top_level = p->top_level;
   initializer_stack = p->next;
   free (p);
+  --parsing_initializer;
 }
 
 /* Call here when we see the initializer is surrounded by braces.


Index: llvm-gcc/gcc/c-common.c
diff -u llvm-gcc/gcc/c-common.c:1.5 llvm-gcc/gcc/c-common.c:1.6
--- llvm-gcc/gcc/c-common.c:1.5	Mon Jan  3 16:03:15 2005
+++ llvm-gcc/gcc/c-common.c	Mon Jan  3 16:13:16 2005
@@ -44,8 +44,7 @@
 #include "toplev.h"
 #include "llvm-out.h"
 
-struct initializer_stack;
-extern struct initializer_stack *initializer_stack;
+int parsing_initializer = 0;
 
 cpp_reader *parse_in;		/* Declared in c-pragma.h.  */
 
@@ -2565,7 +2564,7 @@
 					     TREE_UNSIGNED (sizetype)), intop);
 
   /* Don't create an ARRAY_REF if this is a potentially a static initializer. */
-  if (0 && EMIT_LLVM) {
+  if (EMIT_LLVM && !parsing_initializer) {
     /* In LLVM we really want to represent this as &P[i], not as P+i*sizeof(*P)
      */
     tree arrayref;






More information about the llvm-commits mailing list