[C++1z] Fix crash when decomposing structs with anonymous members.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 12 Aug 2016 09:19:34 +0000 (09:19 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 12 Aug 2016 09:19:34 +0000 (09:19 +0000)
The diagnostic format was invalid.

llvm-svn: 278487

clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/CXX/dcl.decl/dcl.decomp/p4.cpp

index bc62814..788ff19 100644 (file)
@@ -405,8 +405,8 @@ def err_decomp_decl_non_public_base : Error<
 def err_decomp_decl_non_public_member : Error<
   "cannot decompose non-public member %0 of %1">;
 def err_decomp_decl_anon_union_member : Error<
-  "cannot decompose class type %1 because it has an anonymous "
-  "%select{struct|union} member">;
+  "cannot decompose class type %0 because it has an anonymous "
+  "%select{struct|union}1 member">;
 def err_decomp_decl_std_tuple_element_not_specialized : Error<
   "cannot decompose this type; 'std::tuple_element<%0>::type' "
   "does not name a type">;
index ea225cb..c461eb6 100644 (file)
@@ -32,6 +32,25 @@ namespace NonPublicMembers {
   }
 }
 
+namespace AnonymousMember {
+  struct Struct {
+    struct { // expected-note {{declared here}}
+      int i;
+    };
+  };
+
+  struct Union {
+    union { // expected-note {{declared here}}
+      int i;
+    };
+  };
+
+  void test() {
+    auto [a1] = Struct(); // expected-error {{cannot decompose class type 'AnonymousMember::Struct' because it has an anonymous struct member}}
+    auto [a2] = Union(); // expected-error {{cannot decompose class type 'AnonymousMember::Union' because it has an anonymous union member}}
+  }
+}
+
 namespace MultipleClasses {
   struct B : A {
     int a;