Skip to content

Commit ef739e7

Browse files
[clang] Change "bad" to "unsupported" in register type error (#111550)
This is maybe a personal take but I expect "bad" to either mean: * Allowed but not ideal, like a "bad" memory alignment might work but it is slow. * The tool won't allow it but is going to tell me why it didn't. The current error doesn't elaborate so I think it's best we just say "unsupported" instead. This is clear that the type used is not allowed at all.
1 parent b9314a8 commit ef739e7

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,10 @@ Improvements to Clang's diagnostics
372372

373373
- Clang now omits warnings for extra parentheses in fold expressions with single expansion (#GH101863).
374374

375+
- The warning for an unsupported type for a named register variable is now phrased ``unsupported type for named register variable``,
376+
instead of ``bad type for named register variable``. This makes it clear that the type is not supported at all, rather than being
377+
suboptimal in some way the error fails to mention (#GH111550).
378+
375379
Improvements to Clang's time-trace
376380
----------------------------------
377381

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9379,7 +9379,8 @@ let CategoryName = "Inline Assembly Issue" in {
93799379
"global register variables on this target">;
93809380
def err_asm_register_size_mismatch : Error<"size of register '%0' does not "
93819381
"match variable size">;
9382-
def err_asm_bad_register_type : Error<"bad type for named register variable">;
9382+
def err_asm_unsupported_register_type : Error<
9383+
"unsupported type for named register variable">;
93839384
def err_asm_invalid_input_size : Error<
93849385
"invalid input size for constraint '%0'">;
93859386
def err_asm_invalid_output_size : Error<

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7961,7 +7961,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
79617961
}
79627962

79637963
if (!R->isIntegralType(Context) && !R->isPointerType()) {
7964-
Diag(TInfo->getTypeLoc().getBeginLoc(), diag::err_asm_bad_register_type)
7964+
Diag(TInfo->getTypeLoc().getBeginLoc(),
7965+
diag::err_asm_unsupported_register_type)
79657966
<< TInfo->getTypeLoc().getSourceRange();
79667967
NewVD->setInvalidDecl(true);
79677968
}

clang/test/Sema/asm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ void iOutputConstraint(int x){
191191
struct foo {
192192
int a;
193193
};
194-
register struct foo bar asm("esp"); // expected-error {{bad type for named register variable}}
195-
register float baz asm("esp"); // expected-error {{bad type for named register variable}}
194+
register struct foo bar asm("esp"); // expected-error {{unsupported type for named register variable}}
195+
register float baz asm("esp"); // expected-error {{unsupported type for named register variable}}
196196

197197
register int r0 asm ("edi"); // expected-error {{register 'edi' unsuitable for global register variables on this target}}
198198
register long long r1 asm ("esp"); // expected-error {{size of register 'esp' does not match variable size}}

clang/test/Sema/caret-diags-register-variable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ struct foo {
44
int a;
55
};
66

7-
//CHECK: {{.*}}: error: bad type for named register variable
7+
//CHECK: {{.*}}: error: unsupported type for named register variable
88
//CHECK-NEXT: {{^}}register struct foo bar asm("esp");
99
//CHECK-NEXT: {{^}} ^~~~~~~~~~{{$}}
1010
register struct foo bar asm("esp");

0 commit comments

Comments
 (0)