Parsing availability attribute message value

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Parsing availability attribute message value

David Blaikie via cfe-dev

An availability attribute parsing test is failing on XCore. Is this the right fix?

Test file clang/test/Parser/attr-availability.c, function f8, tests that

__attribute__((availability(macosx,message="a" L"b")))

gives error "expected string literal for optional message in 'availability' attribute", because "a" L"b" should be concatenated into a wide string.

The check is made in clang/lib/Parse/ParseDecl.cpp, Parser::ParseAvailabilityAttribute, comment "Also reject wide string literals". But the code checks (1) that the first token in the string concatenation is a (non-wide) string literal, and then (2) that the resulting string consists of 1-byte characters.

On XCore, wchar_t is unsigned char, so "a" L"b" passes both checks, and the expected diagnostic is not issued. But plain L"b" would be rejected. This is inconsistent.

Can I fix:

if (MessageStringLiteral->getCharByteWidth() != 1)

to:

if (!MessageStringLiteral->isAscii())

or is there a reason for the width test specifically?

Thanks,

Nigel

 


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev