From: Chandler Carruth Date: Mon, 27 Jun 2011 16:32:27 +0000 (+0000) Subject: Cleanup a fixme by using a specific diagnostic for subscripting X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6628969c3e3886b68d8a0051df7e222aa50ef118;p=clang Cleanup a fixme by using a specific diagnostic for subscripting a pointer to void. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133912 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 87812febb0..1fae60d4d9 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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; 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< diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index d644e55989..3423d71af4 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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. diff --git a/test/Sema/pointer-addition.c b/test/Sema/pointer-addition.c index af8258a0f2..21ce63b438 100644 --- a/test/Sema/pointer-addition.c +++ b/test/Sema/pointer-addition.c @@ -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;