diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2011-06-27 16:32:27 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2011-06-27 16:32:27 +0000 |
| commit | 4cc3f296a9076457b9f35c5a7403e05cf1217d69 (patch) | |
| tree | 3e0dc09cf57e47e3bd4a110cfc10fd0c912c5f0d | |
| parent | 7a200968744282e586a495997f6775cf3ef94652 (diff) | |
| download | bcm5719-llvm-4cc3f296a9076457b9f35c5a7403e05cf1217d69.tar.gz bcm5719-llvm-4cc3f296a9076457b9f35c5a7403e05cf1217d69.zip | |
Cleanup a fixme by using a specific diagnostic for subscripting
a pointer to void.
llvm-svn: 133912
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 5 | ||||
| -rw-r--r-- | clang/test/Sema/pointer-addition.c | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 87812febb0c..1fae60d4d96 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/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<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< diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index d644e559895..3423d71af4f 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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/clang/test/Sema/pointer-addition.c b/clang/test/Sema/pointer-addition.c index af8258a0f2e..21ce63b4381 100644 --- a/clang/test/Sema/pointer-addition.c +++ b/clang/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; |

