[cfe-dev] clang::Qualifiers::TQ flags are not in sync with DeclSpec::TQ flags

Vladimir Voskresensky via cfe-dev cfe-dev at lists.llvm.org
Mon Aug 7 06:06:25 PDT 2017


Hello,

clang::Qualifiers::TQ has 3 flags and CVRMask mask. Also it has the note:
// NOTE: These flags must be kept in sync with DeclSpec::TQ.

But
DeclSpec::TQ has 5 flags (so  TQ_unaligned = 8, TQ_atomic = 16 are 
missed in clang::Qualifiers::TQ)

This inconsistency can be found by debugging test 
llvm/tools/clang/test/Sema/MicrosoftExtensions.c on the last declaration:
void test_unaligned2(int x[__unaligned 4]) {}

Array type is created incorrectly here, because '__unaligned' is lost in 
the ArrayType constructor at line:
ArrayTypeBits.IndexTypeQuals = tq;
tq has value 8 (TQ_unaligned) while IndexTypeQuals is declared to use 
":3" bits only, so IndexTypeQuals is zero after assign.

Usually TQ fields are 5 bits (see i.e. DeclSpec::TypeQualifiers), so
declaration Type::ArrayTypeBitfields::IndexTypeQuals must be fixed as well

Hope it helps,
Vladimir.






More information about the cfe-dev mailing list