r278487 - [C++1z] Fix crash when decomposing structs with anonymous members.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 12 02:19:35 PDT 2016
Author: d0k
Date: Fri Aug 12 04:19:34 2016
New Revision: 278487
URL: http://llvm.org/viewvc/llvm-project?rev=278487&view=rev
Log:
[C++1z] Fix crash when decomposing structs with anonymous members.
The diagnostic format was invalid.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=278487&r1=278486&r2=278487&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 12 04:19:34 2016
@@ -405,8 +405,8 @@ def err_decomp_decl_non_public_base : Er
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">;
Modified: cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp?rev=278487&r1=278486&r2=278487&view=diff
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp (original)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.decomp/p4.cpp Fri Aug 12 04:19:34 2016
@@ -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;
More information about the cfe-commits
mailing list