Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__noop not marked as constexpr #102064 #105983

Merged
merged 6 commits into from
Aug 30, 2024
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
7 changes: 7 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ Bug Fixes in This Version
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330)

- Clang now allows pointee types of atomic builtin arguments to be complete template types
that was not instantiated elsewhere.

- ``__noop`` can now be used in a constant expression. (#GH102064)

Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Builtins.td
Original file line number Diff line number Diff line change
Expand Up @@ -2518,7 +2518,7 @@ def IsoVolatileStore : MSLangBuiltin, Int8_16_32_64Template {

def Noop : MSLangBuiltin {
let Spellings = ["__noop"];
let Attributes = [NoThrow];
let Attributes = [NoThrow, Constexpr];
let Prototype = "int(...)";
}

Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12719,6 +12719,10 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
return false;
}

case Builtin::BI__noop:
// __noop always evaluates successfully
return true;

case Builtin::BI__builtin_is_constant_evaluated: {
const auto *Callee = Info.CurrentCall->getCallee();
if (Info.InConstantContext && !Info.CheckingPotentialConstantExpression &&
Expand Down
4 changes: 4 additions & 0 deletions clang/test/SemaCXX/builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,7 @@ template void test_builtin_complex(int, double); // expected-note {{instantiatio
static void __builtin_cpu_init(); // expected-error {{static declaration of '__builtin_cpu_init' follows non-static declaration}} \
expected-note {{'__builtin_cpu_init' is a builtin with type 'void () noexcept'}}
#endif

#ifdef _MSC_VER
constexpr int x = []{ __noop; return 0; }(); // expected-no-diagnostics
#endif
Loading