Skip to content

Commit 66f5e46

Browse files
committed
Address feedback
1 parent 1df580b commit 66f5e46

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ Bug Fixes to AST Handling
452452

453453
Miscellaneous Bug Fixes
454454
^^^^^^^^^^^^^^^^^^^^^^^
455-
- Fixed missing diagnostics of ``diagnose_if`` on a constructor template involved in initialization. (#GH160776)
455+
- Fixed missing diagnostics of ``diagnose_if`` on templates involved in initialization. (#GH160776)
456456

457457
Miscellaneous Clang Crashes Fixed
458458
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/test/SemaCXX/diagnose_if.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++20
2-
// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++20 -fexperimental-new-constant-interpreter
1+
// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++14
2+
// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++20 -verify=expected,cxx20
3+
// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++14 -fexperimental-new-constant-interpreter
4+
// RUN: %clang_cc1 %s -verify -fno-builtin -std=c++20 -verify=expected,cxx20 -fexperimental-new-constant-interpreter
35

46
#define _diagnose_if(...) __attribute__((diagnose_if(__VA_ARGS__)))
57

@@ -673,17 +675,20 @@ struct ConstructorTemplate {
673675
explicit ConstructorTemplate(T x)
674676
_diagnose_if(sizeof(T) == sizeof(char), "oh no", "error") {} // expected-note {{diagnose_if}}
675677

676-
template <class T> requires (sizeof(T) == 1) // expected-note {{evaluated to false}}
678+
template <class T>
679+
#if __cplusplus >= 202002L
680+
requires (sizeof(T) == 1) // cxx20-note {{evaluated to false}}
681+
#endif
677682
operator T() _diagnose_if(sizeof(T) == sizeof(char), "oh no", "error") { // expected-note {{diagnose_if}} \
678-
// expected-note {{constraints not satisfied}}
683+
// cxx20-note {{constraints not satisfied}}
679684
return T{};
680685
}
681686
};
682687

683688
void run() {
684689
ConstructorTemplate x('1'); // expected-error {{oh no}}
685690
char y = x; // expected-error {{oh no}}
686-
int z = x; // expected-error {{no viable conversion}}
691+
int z = x; // cxx20-error {{no viable conversion}}
687692
}
688693

689694
}

0 commit comments

Comments
 (0)