class CharLiteralParser {
uint64_t Value;
bool IsWide;
+ bool IsMultiChar;
bool HadError;
public:
CharLiteralParser(const char *begin, const char *end,
bool hadError() const { return HadError; }
bool isWide() const { return IsWide; }
+ bool isMultiChar() const { return IsMultiChar; }
uint64_t getValue() const { return Value; }
};
PP.Diag(Loc, diag::ext_multichar_character_literal);
else
PP.Diag(Loc, diag::ext_four_char_character_literal);
+ IsMultiChar = true;
}
// Transfer the value from APInt to uint64_t
// Character literals are always int or wchar_t, expand to intmax_t.
TargetInfo &TI = PP.getTargetInfo();
- unsigned NumBits = TI.getCharWidth(Literal.isWide());
-
+ unsigned NumBits;
+ if (Literal.isMultiChar())
+ NumBits = TI.getIntWidth();
+ else
+ NumBits = TI.getCharWidth(Literal.isWide());
+
// Set the width.
llvm::APSInt Val(NumBits);
// Set the value.
--- /dev/null
+// RUN: clang-cc < %s -E -verify -triple i686-pc-linux-gnu
+
+#if (('1234' >> 24) != '1')
+#error Bad multichar constant calculation!
+#endif