[PATCH] D155545: [clang][Interp] Pass CallExpr to builtin functions
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 18 12:38:57 PDT 2023
aaron.ballman added inline comments.
================
Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:78-79
+
+ if (!isa<StringLiteral>(Call->getArg(0)->IgnoreParenCasts()))
+ return false;
+
----------------
Hmmm, I think I missed a situation when we were talking about this. Consider: https://godbolt.org/z/14dz5MMPj
I think the current interpreter is wrong to reject that code (I think the GCC behavior is correct). If you remove the `constexpr` from the declaration of `Nan2`, it compiles fine.
WDYT?
================
Comment at: clang/test/AST/Interp/builtin-functions.cpp:44
- constexpr float Nan2 = __builtin_nans([](){return "0xAE98";}()); // ref-error {{must be initialized by a constant expression}}
+ constexpr float Nan2 = __builtin_nans([](){return "0xAE98";}()); // ref-error {{must be initialized by a constant expression}} \
+ // expected-error {{must be initialized by a constant expression}}
----------------
I mentioned this on another review, but I think the current interpreter is wrong to reject this because that lambda is constexpr-suitable.
http://eel.is/c++draft/expr.prim.lambda#closure-5
http://eel.is/c++draft/dcl.constexpr#3
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155545/new/
https://reviews.llvm.org/D155545
More information about the cfe-commits
mailing list