Tyker marked 2 inline comments as done. Tyker added a comment. sorry i didn't realize the full complexity of immediate invocations. i am working on a patch fixing issues.
================ Comment at: clang/lib/Sema/SemaExpr.cpp:5761-5762 // in ArgExprs. - if ((FDecl = - rewriteBuiltinFunctionDecl(this, Context, FDecl, ArgExprs))) { + if ((FDecl = rewriteBuiltinFunctionDecl(this, Context, FDecl, ArgExprs, + /*Diagnose*/ false))) { NDecl = FDecl; ---------------- rsmith wrote: > What's the purpose of this change? this change was to prevent a double error message for code like: ``` consteval f() { return 0; } auto* p = __builtin_addressof(f); ``` it is going to disappear because the error reporting locations are going to move. ================ Comment at: clang/lib/Sema/SemaOverload.cpp:9596-9607 + if (!S.isConstantEvaluated() && FD->isConsteval()) { + if (Complain) { + if (InOverloadResolution) + S.Diag(FD->getBeginLoc(), diag::note_addrof_ovl_consteval); + else { + S.Diag(Loc, diag::err_invalid_consteval_take_address) << FD; + S.Diag(FD->getBeginLoc(), diag::note_declared_at); ---------------- rsmith wrote: > This isn't the right way to deal with this, in part because we don't know > whether we're in an immediate invocation or not at this point. Instead, we > should track that we saw a use of a `consteval` function from > `Sema::DiagnoseUseOfDecl`, and issue a diagnostic if that use is not within > an immediate invocation / within a consteval function. from what i understood Sema::DiagnoseUseOfDecl is called as soon as the Decl is used. but there is some cases similar to the one you gave in an other comment where we can't know yet if the use is during an immediate invokation. like the following ``` enum E {}; consteval int operator+(int (*f)(), E) { return f(); } consteval int fn() { return 42; } int k = &fn + E(); ``` this should be valid i think. but at the point of call of Sema::DiagnoseUseOfDecl for the use of fn we don't know yet that we are in an immediate invokation. so i think this check should be delayed until we know the bounds of the immediate invokation. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63960/new/ https://reviews.llvm.org/D63960 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits