File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -1030,14 +1030,17 @@ bool ByteCodeExprGen<Emitter>::VisitSubstNonTypeTemplateParmExpr(
1030
1030
1031
1031
template <class Emitter >
1032
1032
bool ByteCodeExprGen<Emitter>::VisitConstantExpr(const ConstantExpr *E) {
1033
- // Try to emit the APValue directly, without visiting the subexpr.
1034
- // This will only fail if we can't emit the APValue, so won't emit any
1035
- // diagnostics or any double values.
1036
1033
std::optional<PrimType> T = classify (E->getType ());
1037
- if (T && E->hasAPValueResult () &&
1038
- this ->visitAPValue (E->getAPValueResult (), *T, E))
1039
- return true ;
1034
+ if (T && E->hasAPValueResult ()) {
1035
+ // Try to emit the APValue directly, without visiting the subexpr.
1036
+ // This will only fail if we can't emit the APValue, so won't emit any
1037
+ // diagnostics or any double values.
1038
+ if (DiscardResult)
1039
+ return true ;
1040
1040
1041
+ if (this ->visitAPValue (E->getAPValueResult (), *T, E))
1042
+ return true ;
1043
+ }
1041
1044
return this ->delegate (E->getSubExpr ());
1042
1045
}
1043
1046
Original file line number Diff line number Diff line change @@ -752,3 +752,16 @@ namespace TryCatch {
752
752
}
753
753
static_assert (foo() == 11 );
754
754
}
755
+
756
+ namespace IgnoredConstantExpr {
757
+ consteval int immediate () { return 0 ;}
758
+ struct ReferenceToNestedMembers {
759
+ int m;
760
+ int a = ((void )immediate(), m);
761
+ int b = ((void )immediate(), this ->m);
762
+ };
763
+ struct ReferenceToNestedMembersTest {
764
+ void * m = nullptr ;
765
+ ReferenceToNestedMembers j{0 };
766
+ } test_reference_to_nested_members;
767
+ }
Original file line number Diff line number Diff line change 1
1
// RUN: %clang_cc1 -std=c++11 -verify %s -pedantic
2
+ // RUN: %clang_cc1 -std=c++11 -verify %s -pedantic -fexperimental-new-constant-interpreter
2
3
// RUN: %clang_cc1 -std=c++20 -verify %s -pedantic
4
+ // RUN: %clang_cc1 -std=c++20 -verify %s -pedantic -fexperimental-new-constant-interpreter
3
5
4
6
5
7
namespace PR31692 {
You can’t perform that action at this time.
0 commit comments