Patchwork PR 57541

login
register
mail settings
Submitter Iyer, Balaji V
Date June 7, 2013, 10:07 p.m.
Message ID <BF230D13CA30DD48930C31D4099330003A42C054@FMSMSX101.amr.corp.intel.com>
Download mbox | patch
Permalink /patch/249856/
State New
Headers show

Comments

Iyer, Balaji V - June 7, 2013, 10:07 p.m.
Hello Everyone,
	This patch below should fix the bug reported in PR 57541. The following statements were not caught by the array notation expander, and they should be caught and replaced with zero nodes:

A[:];
A[x:y];
A[x:y:z];

Here are the Changelogs 

gcc/c/ChangeLog
2013-06-07  Balaji V. Iyer  <balaji.v.iyer@intel.com>
        * c-array-notation.c (expand_array_notation_exprs): Added
        ARRAY_NOTATION_REF case.

gcc/testsuite/ChangeLog
2013-06-07  Balaji V. Iyer  <balaji.v.iyer@intel.com>

        PR middle-end/57541
        * c-c++-common/cilk-plus/AN/pr57541.c: New test case.


... and the patch cut and pasted below:


Since this is a trivial patch, I will commit this in. I am willing to revert it (and/or fix it) if anyone has objections.

Thanks,

Balaji V. Iyer.

Patch

Index: gcc/c/c-array-notation.c
===================================================================
--- gcc/c/c-array-notation.c    (revision 199825)
+++ gcc/c/c-array-notation.c    (working copy)
@@ -2317,6 +2317,14 @@ 
     case RETURN_EXPR:
       if (contains_array_notation_expr (t))
        t = fix_return_expr (t);
+      return t;
+    case ARRAY_NOTATION_REF:
+      /* IF we are here, then we are dealing with cases like this:
+        A[:];
+        A[x:y:z];
+        A[x:y];
+        Replace those with just void zero node.  */
+      t = void_zero_node;
     default:
       return t;
     }
Index: gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c
===================================================================
--- gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c   (revision 0)
+++ gcc/testsuite/c-c++-common/cilk-plus/AN/pr57541.c   (revision 0)
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+int A[10];
+
+int main () {
+  char c = (char)N; /* { dg-error "undeclared" } */
+  short s = (short)N;
+  long l = (long)N;
+  A[l:s:c];
+}
+
+/* { dg-message "note: each" "defined" { target *-*-* }  7 } */
+