Cleanup a fixme by using a specific diagnostic for subscripting

a pointer to void.

llvm-svn: 133912
This commit is contained in:
Chandler Carruth 2011-06-27 16:32:27 +00:00
parent 7a20096874
commit 4cc3f296a9
3 changed files with 5 additions and 4 deletions

View 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<

View 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.

View 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;