]> granicus.if.org Git - clang/commitdiff
Cleanup a fixme by using a specific diagnostic for subscripting
authorChandler Carruth <chandlerc@gmail.com>
Mon, 27 Jun 2011 16:32:27 +0000 (16:32 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 27 Jun 2011 16:32:27 +0000 (16:32 +0000)
a pointer to void.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133912 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/Sema/pointer-addition.c

index 87812febb0c02f3397f62dd1c81410691b3e222f..1fae60d4d96883dfa7ea1fc846d2e4ebe3fe7460 100644 (file)
@@ -2838,6 +2838,8 @@ def err_subscript_function_type : Error<
   "subscript of pointer to function type %0">;
 def err_subscript_incomplete_type : Error<
   "subscript of pointer to incomplete type %0">;
+def ext_gnu_subscript_void_type : Extension<
+  "subscript of a pointer to void is a GNU extension">, InGroup<PointerArith>;
 def err_typecheck_member_reference_struct_union : Error<
   "member reference base type %0 is not a structure or union">;
 def err_typecheck_member_reference_ivar : Error<
index d644e5598951943003a5be4a0039647ce8daffc1..3423d71af4f3807f33440693f8e45964985cbda2 100644 (file)
@@ -3092,9 +3092,8 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
 
   if (ResultType->isVoidType() && !getLangOptions().CPlusPlus) {
     // GNU extension: subscripting on pointer to void
-    // FIXME: Use a better warning for this.
-    Diag(LLoc, diag::ext_gnu_void_ptr)
-      << 0 << BaseExpr->getSourceRange();
+    Diag(LLoc, diag::ext_gnu_subscript_void_type)
+      << BaseExpr->getSourceRange();
 
     // C forbids expressions of unqualified void type from being l-values.
     // See IsCForbiddenLValueType.
index af8258a0f2e92670fbdb0e604033cac151106517..21ce63b4381fc35b2dfcc9a872d1662913034c7d 100644 (file)
@@ -9,7 +9,7 @@ void a(S* b, void* c) {
   c += 1;    // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
   c--;       // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
   c -= 1;    // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
-  (void) c[1]; // expected-warning {{arithmetic on a pointer to void is a GNU extension}}
+  (void) c[1]; // expected-warning {{subscript of a pointer to void is a GNU extension}}
   b = 1+b;   // expected-error {{arithmetic on a pointer to an incomplete type}}
   /* The next couple tests are only pedantic warnings in gcc */
   void (*d)(S*,void*) = a;