Hello.

With reference to this message
     http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-August/010509.html
here is a patch demoting the error into an extension warning.

OK to commit?



Index: test/Sema/pointer-addition.c
===================================================================
--- test/Sema/pointer-addition.c	(revision 113725)
+++ test/Sema/pointer-addition.c	(working copy)
@@ -9,6 +9,7 @@
   c += 1;    // expected-warning {{use of GNU void* extension}}
   c--;       // expected-warning {{use of GNU void* extension}}
   c -= 1;    // expected-warning {{use of GNU void* extension}}
+  (void) c[1]; // expected-warning {{use of GNU void* extension}}
   b = 1+b;   // expected-error {{arithmetic on pointer to incomplete type}}
   /* The next couple tests are only pedantic warnings in gcc */
   void (*d)(S*,void*) = a;
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp	(revision 113725)
+++ lib/Sema/SemaExpr.cpp	(working copy)
@@ -2418,7 +2418,11 @@
     return ExprError();
   }
 
-  if (!ResultType->isDependentType() &&
+  if (ResultType->isVoidType() && !getLangOptions().CPlusPlus) {
+    // GNU extension: subscripting on pointer to void
+    Diag(LLoc, diag::ext_gnu_void_ptr)
+      << BaseExpr->getSourceRange();
+  } else if (!ResultType->isDependentType() &&
       RequireCompleteType(LLoc, ResultType,
                           PDiag(diag::err_subscript_incomplete_type)
                             << BaseExpr->getSourceRange()))
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to