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
This commit is contained in:
Chandler Carruth 2011-06-27 16:32:27 +00:00
Родитель d944a9b7a6
Коммит 6628969c3e
3 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -2838,6 +2838,8 @@ def err_subscript_function_type : Error<
"subscript of pointer to function type %0">; "subscript of pointer to function type %0">;
def err_subscript_incomplete_type : Error< def err_subscript_incomplete_type : Error<
"subscript of pointer to incomplete type %0">; "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< def err_typecheck_member_reference_struct_union : Error<
"member reference base type %0 is not a structure or union">; "member reference base type %0 is not a structure or union">;
def err_typecheck_member_reference_ivar : Error< def err_typecheck_member_reference_ivar : Error<

Просмотреть файл

@ -3092,9 +3092,8 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
if (ResultType->isVoidType() && !getLangOptions().CPlusPlus) { if (ResultType->isVoidType() && !getLangOptions().CPlusPlus) {
// GNU extension: subscripting on pointer to void // GNU extension: subscripting on pointer to void
// FIXME: Use a better warning for this. Diag(LLoc, diag::ext_gnu_subscript_void_type)
Diag(LLoc, diag::ext_gnu_void_ptr) << BaseExpr->getSourceRange();
<< 0 << BaseExpr->getSourceRange();
// C forbids expressions of unqualified void type from being l-values. // C forbids expressions of unqualified void type from being l-values.
// See IsCForbiddenLValueType. // See IsCForbiddenLValueType.

Просмотреть файл

@ -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 += 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--; // 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}} 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}} b = 1+b; // expected-error {{arithmetic on a pointer to an incomplete type}}
/* The next couple tests are only pedantic warnings in gcc */ /* The next couple tests are only pedantic warnings in gcc */
void (*d)(S*,void*) = a; void (*d)(S*,void*) = a;