-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang] Fix consteval propagation for aggregates and defaulted constr…
…uctors This patch does a few things: * Fix aggregate initialization. When an aggregate has an initializer that is immediate-escalating, the context in which it is used automatically becomes an immediate function. The wording does that by rpretending an aggregate initialization is itself an invocation which is not really how clang works, so my previous attempt was... wrong. * Fix initialization of defaulted constructors with immediate escalating default member initializers. The wording was silent about that case and I did not handled it fully https://cplusplus.github.io/CWG/issues/2760.html * Fix diagnostics In some cases clang would produce additional and unhelpful diagnostics by listing the invalid references to consteval function that appear in immediate escalating functions Fixes #63742 Reviewed By: aaron.ballman, #clang-language-wg, Fznamznon Differential Revision: https://reviews.llvm.org/D155175
- Loading branch information
Showing
11 changed files
with
299 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %clang_cc1 -emit-llvm %s -std=c++20 -triple x86_64-unknown-linux-gnu -o - | FileCheck %s | ||
|
||
namespace GH63742 { | ||
|
||
void side_effect(); | ||
consteval int f(int x) { | ||
if (!__builtin_is_constant_evaluated()) side_effect(); | ||
return x; | ||
} | ||
struct SS { | ||
int x = f(42); | ||
SS(); | ||
}; | ||
SS::SS(){} | ||
|
||
} | ||
|
||
// CHECK-LABEL: @_ZN7GH637422SSC2Ev | ||
// CHECK-NOT: call | ||
// CHECK: store i32 42, ptr {{.*}} | ||
// CHECK: ret void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.