Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ Bug Fixes in This Version
the unsupported type instead of the ``register`` keyword (#GH109776).
- Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
- Fixed a crash when GNU statement expression contains invalid statement (#GH113468).
- Fixed a failed assertion when using ``__attribute__((noderef))`` on an
``_Atomic``-qualified type (#GH116124).

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
51 changes: 27 additions & 24 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5837,6 +5837,30 @@ static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
llvm_unreachable("no matrix_type attribute found at the expected location!");
}

static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk) {
SourceLocation Loc;
switch (Chunk.Kind) {
case DeclaratorChunk::Function:
case DeclaratorChunk::Array:
case DeclaratorChunk::Paren:
case DeclaratorChunk::Pipe:
llvm_unreachable("cannot be _Atomic qualified");

case DeclaratorChunk::Pointer:
Loc = Chunk.Ptr.AtomicQualLoc;
break;

case DeclaratorChunk::BlockPointer:
case DeclaratorChunk::Reference:
case DeclaratorChunk::MemberPointer:
// FIXME: Provide a source location for the _Atomic keyword.
break;
}

ATL.setKWLoc(Loc);
ATL.setParensRange(SourceRange());
}

namespace {
class TypeSpecLocFiller : public TypeLocVisitor<TypeSpecLocFiller> {
Sema &SemaRef;
Expand Down Expand Up @@ -6223,6 +6247,9 @@ namespace {
void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
TL.setNameLoc(Chunk.Loc);
}
void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
fillAtomicQualLoc(TL, Chunk);
}
void
VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
TL.setNameLoc(Chunk.Loc);
Expand All @@ -6237,30 +6264,6 @@ namespace {
};
} // end anonymous namespace

static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk) {
SourceLocation Loc;
switch (Chunk.Kind) {
case DeclaratorChunk::Function:
case DeclaratorChunk::Array:
case DeclaratorChunk::Paren:
case DeclaratorChunk::Pipe:
llvm_unreachable("cannot be _Atomic qualified");

case DeclaratorChunk::Pointer:
Loc = Chunk.Ptr.AtomicQualLoc;
break;

case DeclaratorChunk::BlockPointer:
case DeclaratorChunk::Reference:
case DeclaratorChunk::MemberPointer:
// FIXME: Provide a source location for the _Atomic keyword.
break;
}

ATL.setKWLoc(Loc);
ATL.setParensRange(SourceRange());
}

static void
fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL,
const ParsedAttributesView &Attrs) {
Expand Down
5 changes: 5 additions & 0 deletions clang/test/Frontend/noderef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,8 @@ int *const_cast_check(NODEREF const int *x) {
const int *const_cast_check(NODEREF int *x) {
return const_cast<const int *>(x); // expected-warning{{casting to dereferenceable pointer removes 'noderef' attribute}}
}

namespace GH116124 {
// This declaration would previously cause a failed assertion.
int *_Atomic a __attribute__((noderef));
}
Loading