Skip to content

Commit e0fa2f1

Browse files
authored
__noop not marked as constexpr #102064 (#105983)
Fixes #102064
1 parent d6ad551 commit e0fa2f1

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ Bug Fixes in This Version
285285
Bug Fixes to Compiler Builtins
286286
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
287287

288+
- Fix crash when atomic builtins are called with pointer to zero-size struct (#GH90330)
289+
290+
- Clang now allows pointee types of atomic builtin arguments to be complete template types
291+
that was not instantiated elsewhere.
292+
293+
- ``__noop`` can now be used in a constant expression. (#GH102064)
294+
288295
Bug Fixes to Attribute Support
289296
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
290297

clang/include/clang/Basic/Builtins.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,7 @@ def IsoVolatileStore : MSLangBuiltin, Int8_16_32_64Template {
25182518

25192519
def Noop : MSLangBuiltin {
25202520
let Spellings = ["__noop"];
2521-
let Attributes = [NoThrow];
2521+
let Attributes = [NoThrow, Constexpr];
25222522
let Prototype = "int(...)";
25232523
}
25242524

clang/lib/AST/ExprConstant.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12719,6 +12719,10 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1271912719
return false;
1272012720
}
1272112721

12722+
case Builtin::BI__noop:
12723+
// __noop always evaluates successfully
12724+
return true;
12725+
1272212726
case Builtin::BI__builtin_is_constant_evaluated: {
1272312727
const auto *Callee = Info.CurrentCall->getCallee();
1272412728
if (Info.InConstantContext && !Info.CheckingPotentialConstantExpression &&

clang/test/SemaCXX/builtins.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,7 @@ template void test_builtin_complex(int, double); // expected-note {{instantiatio
175175
static void __builtin_cpu_init(); // expected-error {{static declaration of '__builtin_cpu_init' follows non-static declaration}} \
176176
expected-note {{'__builtin_cpu_init' is a builtin with type 'void () noexcept'}}
177177
#endif
178+
179+
#ifdef _MSC_VER
180+
constexpr int x = []{ __noop; return 0; }(); // expected-no-diagnostics
181+
#endif

0 commit comments

Comments
 (0)