[cfe-dev] Parsing availability attribute message value

Nigel Perks via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 16 07:50:32 PST 2020


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201116/b080e020/attachment.html>


More information about the cfe-dev mailing list