Skip to content

Commit 9897139

Browse files
committed
Diagnostic fix ups
1 parent cc26d46 commit 9897139

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6724,19 +6724,16 @@ def err_counted_by_on_incomplete_type_on_assign : Error <
67246724

67256725
def err_counted_by_on_incomplete_type_on_use : Error <
67266726
"cannot %select{"
6727-
"use '%1'|" // Generic expr
6728-
"call '%1'" // CallExpr
6729-
"}0 with%select{"
6730-
"|" // Generic expr
6731-
" return" // CallExpr
6732-
"}0 '%4' attributed type %2 because the pointee type %3 is incomplete">;
6727+
"use '%1' with '%4' attributed|" // Generic expr
6728+
"call '%1' with '%4' attributed return" // CallExpr
6729+
"}0 type %2 because the pointee type %3 is incomplete">;
67336730

67346731
def note_counted_by_consider_completing_pointee_ty : Note<
67356732
"consider providing a complete definition for %0">;
67366733

67376734
def note_counted_by_consider_using_sized_by : Note<
67386735
"consider using '__sized_by%select{|_or_null}0' instead of "
6739-
"__counted_by%select{|_or_null}0">;
6736+
"'__counted_by%select{|_or_null}0'">;
67406737

67416738
def warn_counted_by_attr_elt_type_unknown_size :
67426739
Warning<err_counted_by_attr_pointee_unknown_size.Summary>,

clang/test/Sema/attr-counted-by-or-null-struct-ptrs-completable-incomplete-pointee.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ typedef struct IncompleteTy Incomplete_t;
2121

2222
struct CBBufDeclPos {
2323
int count;
24-
struct IncompleteTy* buf __counted_by_or_null(count); // OK expected-note 27{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
25-
Incomplete_t* buf_typedef __counted_by_or_null(count); // OK expected-note 27{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
24+
struct IncompleteTy* buf __counted_by_or_null(count); // OK expected-note 27{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
25+
Incomplete_t* buf_typedef __counted_by_or_null(count); // OK expected-note 27{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
2626
};
2727

2828
void consume_struct_IncompleteTy(struct IncompleteTy* buf);
@@ -359,8 +359,8 @@ void consume_struct_IncompleteTy2(struct IncompleteTy2* buf);
359359

360360
struct CBBufTyPos {
361361
int count;
362-
struct IncompleteTy2* __counted_by_or_null(count) buf ; // OK expected-note 8{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
363-
Incomplete_ty2 *__counted_by_or_null(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
362+
struct IncompleteTy2* __counted_by_or_null(count) buf ; // OK expected-note 8{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
363+
Incomplete_ty2 *__counted_by_or_null(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
364364
};
365365

366366
void use_CBBufTyPos(struct CBBufTyPos* ptr) {
@@ -433,8 +433,8 @@ void consume_struct_IncompleteUnionTy(union IncompleteUnionTy* buf);
433433

434434
struct CBBufUnionTyPos {
435435
int count;
436-
union IncompleteUnionTy* __counted_by_or_null(count) buf ; // OK expected-note 8{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
437-
IncompleteUnion_ty *__counted_by_or_null(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
436+
union IncompleteUnionTy* __counted_by_or_null(count) buf ; // OK expected-note 8{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
437+
IncompleteUnion_ty *__counted_by_or_null(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
438438
};
439439

440440
void use_CBBufUnionTyPos(struct CBBufUnionTyPos* ptr) {
@@ -507,8 +507,8 @@ void consume_struct_IncompleteEnumTy(enum IncompleteEnumTy* buf);
507507

508508
struct CBBufEnumTyPos {
509509
int count;
510-
enum IncompleteEnumTy* __counted_by_or_null(count) buf ; // OK expected-note 8{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
511-
IncompleteEnum_ty *__counted_by_or_null(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by_or_null' instead of __counted_by_or_null}}
510+
enum IncompleteEnumTy* __counted_by_or_null(count) buf ; // OK expected-note 8{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
511+
IncompleteEnum_ty *__counted_by_or_null(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by_or_null' instead of '__counted_by_or_null'}}
512512
};
513513

514514
void use_CBBufEnumTyPos(struct CBBufEnumTyPos* ptr) {

clang/test/Sema/attr-counted-by-struct-ptrs-completable-incomplete-pointee.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ typedef struct IncompleteTy Incomplete_t;
2121

2222
struct CBBufDeclPos {
2323
int count;
24-
struct IncompleteTy* buf __counted_by(count); // OK expected-note 27{{consider using '__sized_by' instead of __counted_by}}
25-
Incomplete_t* buf_typedef __counted_by(count); // OK expected-note 27{{consider using '__sized_by' instead of __counted_by}}
24+
struct IncompleteTy* buf __counted_by(count); // OK expected-note 27{{consider using '__sized_by' instead of '__counted_by'}}
25+
Incomplete_t* buf_typedef __counted_by(count); // OK expected-note 27{{consider using '__sized_by' instead of '__counted_by'}}
2626
};
2727

2828
void consume_struct_IncompleteTy(struct IncompleteTy* buf);
@@ -359,8 +359,8 @@ void consume_struct_IncompleteTy2(struct IncompleteTy2* buf);
359359

360360
struct CBBufTyPos {
361361
int count;
362-
struct IncompleteTy2* __counted_by(count) buf ; // OK expected-note 8{{consider using '__sized_by' instead of __counted_by}}
363-
Incomplete_ty2 *__counted_by(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by' instead of __counted_by}}
362+
struct IncompleteTy2* __counted_by(count) buf ; // OK expected-note 8{{consider using '__sized_by' instead of '__counted_by'}}
363+
Incomplete_ty2 *__counted_by(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by' instead of '__counted_by'}}
364364
};
365365

366366
void use_CBBufTyPos(struct CBBufTyPos* ptr) {
@@ -433,8 +433,8 @@ void consume_struct_IncompleteUnionTy(union IncompleteUnionTy* buf);
433433

434434
struct CBBufUnionTyPos {
435435
int count;
436-
union IncompleteUnionTy* __counted_by(count) buf ; // OK expected-note 8{{consider using '__sized_by' instead of __counted_by}}
437-
IncompleteUnion_ty *__counted_by(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by' instead of __counted_by}}
436+
union IncompleteUnionTy* __counted_by(count) buf ; // OK expected-note 8{{consider using '__sized_by' instead of '__counted_by'}}
437+
IncompleteUnion_ty *__counted_by(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by' instead of '__counted_by'}}
438438
};
439439

440440
void use_CBBufUnionTyPos(struct CBBufUnionTyPos* ptr) {
@@ -507,8 +507,8 @@ void consume_struct_IncompleteEnumTy(enum IncompleteEnumTy* buf);
507507

508508
struct CBBufEnumTyPos {
509509
int count;
510-
enum IncompleteEnumTy* __counted_by(count) buf ; // OK expected-note 8{{consider using '__sized_by' instead of __counted_by}}
511-
IncompleteEnum_ty *__counted_by(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by' instead of __counted_by}}
510+
enum IncompleteEnumTy* __counted_by(count) buf ; // OK expected-note 8{{consider using '__sized_by' instead of '__counted_by'}}
511+
IncompleteEnum_ty *__counted_by(count) buf_typedef; // OK expected-note 8{{consider using '__sized_by' instead of '__counted_by'}}
512512
};
513513

514514
void use_CBBufEnumTyPos(struct CBBufEnumTyPos* ptr) {

0 commit comments

Comments
 (0)