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 @@ -379,6 +379,8 @@ Bug Fixes to C++ Support
the function type.
- Fix an assertion failure when a ``constexpr`` variable is only referenced through
``__builtin_addressof``, and related issues with builtin arguments. (#GH154034)
- Fix an assertion failure when taking the address on a non-type template parameter argument of
object type. (#GH151531)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14725,8 +14725,9 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
return MPTy;
}
}
} else if (!isa<FunctionDecl, NonTypeTemplateParmDecl, BindingDecl,
MSGuidDecl, UnnamedGlobalConstantDecl>(dcl))
} else if (!isa<FunctionDecl, TemplateParamObjectDecl,
NonTypeTemplateParmDecl, BindingDecl, MSGuidDecl,
UnnamedGlobalConstantDecl>(dcl))
llvm_unreachable("Unknown/unexpected decl type");
}

Expand Down
15 changes: 15 additions & 0 deletions clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,18 @@ namespace ReportedRegression2 {
fn<str>();
}
}

namespace GH151531 {
struct w {
int n;
};

template <const w *X> void f() { static_assert(X->n == 42); }

template <w X> void g() { f<&X>(); }

void test() {
constexpr w X = {42};
g<X>();
}
}