Author: chandlerc
Date: Mon Jun 27 11:32:27 2011
New Revision: 133912

URL: http://llvm.org/viewvc/llvm-project?rev=133912&view=rev
Log:
Cleanup a fixme by using a specific diagnostic for subscripting
a pointer to void.

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

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=133912&r1=133911&r2=133912&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jun 27 11:32:27 
2011
@@ -2838,6 +2838,8 @@
   "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<

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=133912&r1=133911&r2=133912&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jun 27 11:32:27 2011
@@ -3092,9 +3092,8 @@
 
   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.

Modified: cfe/trunk/test/Sema/pointer-addition.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pointer-addition.c?rev=133912&r1=133911&r2=133912&view=diff
==============================================================================
--- cfe/trunk/test/Sema/pointer-addition.c (original)
+++ cfe/trunk/test/Sema/pointer-addition.c Mon Jun 27 11:32:27 2011
@@ -9,7 +9,7 @@
   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;


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to