Skip to content

Commit f93aed6

Browse files
committed
Fix diagnostics where _Atomic can't be applied
adb290d added a new case to err_atomic_specifier_bad_type. The diagnostic has two %select's controlled by the same argument, but only the first was updated to have the new case. Add the extra case for the second %select and add a test case that exercises the last case.
1 parent 4805901 commit f93aed6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5946,7 +5946,7 @@ def err_func_def_incomplete_result : Error<
59465946
def err_atomic_specifier_bad_type : Error<
59475947
"_Atomic cannot be applied to "
59485948
"%select{incomplete |array |function |reference |atomic |qualified |sizeless |}0type "
5949-
"%1 %select{||||||which is not trivially copyable}0">;
5949+
"%1 %select{|||||||which is not trivially copyable}0">;
59505950

59515951
// Expressions.
59525952
def select_unary_expr_or_type_trait_kind : TextSubstitution<

clang/test/SemaCXX/atomic-type.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,11 @@ namespace copy_init {
103103
bool PR21836(_Atomic(int) *x) { // expected-warning {{'_Atomic' is a C11 extension}}
104104
return *x;
105105
}
106+
107+
namespace non_trivially_copyable {
108+
struct S {
109+
~S() {}
110+
};
111+
_Atomic S s; // expected-error {{_Atomic cannot be applied to type 'non_trivially_copyable::S' which is not trivially copyable}} \
112+
// expected-warning {{'_Atomic' is a C11 extension}}
113+
}

0 commit comments

Comments
 (0)