[clang] f93aed6 - Fix diagnostics where _Atomic can't be applied

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 31 17:33:46 PDT 2020


Author: Weverything
Date: 2020-03-31T17:23:35-07:00
New Revision: f93aed66f22f230213a99205f8bcec975c45d8ba

URL: https://github.com/llvm/llvm-project/commit/f93aed66f22f230213a99205f8bcec975c45d8ba
DIFF: https://github.com/llvm/llvm-project/commit/f93aed66f22f230213a99205f8bcec975c45d8ba.diff

LOG: Fix diagnostics where _Atomic can't be applied

adb290d97482aa9311ee4b4b5917a0f2ece55b30 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.

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticSemaKinds.td
    clang/test/SemaCXX/atomic-type.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 61bf2535e127..951a955984f6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5946,7 +5946,7 @@ def err_func_def_incomplete_result : Error<
 def err_atomic_specifier_bad_type : Error<
   "_Atomic cannot be applied to "
   "%select{incomplete |array |function |reference |atomic |qualified |sizeless |}0type "
-  "%1 %select{||||||which is not trivially copyable}0">;
+  "%1 %select{|||||||which is not trivially copyable}0">;
 
 // Expressions.
 def select_unary_expr_or_type_trait_kind : TextSubstitution<

diff  --git a/clang/test/SemaCXX/atomic-type.cpp b/clang/test/SemaCXX/atomic-type.cpp
index 1ed321e47b9a..d7d8bbba50ca 100644
--- a/clang/test/SemaCXX/atomic-type.cpp
+++ b/clang/test/SemaCXX/atomic-type.cpp
@@ -103,3 +103,11 @@ namespace copy_init {
 bool PR21836(_Atomic(int) *x) { // expected-warning {{'_Atomic' is a C11 extension}}
     return *x;
 }
+
+namespace non_trivially_copyable {
+  struct S {
+    ~S() {}
+  };
+  _Atomic S s;  // expected-error {{_Atomic cannot be applied to type 'non_trivially_copyable::S' which is not trivially copyable}} \
+                // expected-warning {{'_Atomic' is a C11 extension}}
+}


        


More information about the cfe-commits mailing list