]> granicus.if.org Git - clang/commitdiff
Add a missing case for default constructor deletion.
authorSean Hunt <scshunt@csclub.uwaterloo.ca>
Fri, 20 May 2011 21:43:47 +0000 (21:43 +0000)
committerSean Hunt <scshunt@csclub.uwaterloo.ca>
Fri, 20 May 2011 21:43:47 +0000 (21:43 +0000)
This case is tested by the fact that the modified test produces
significatly worse diagnostics. That's on the list.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131759 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/value-initialization.cpp

index 90c840ba7faa150263dacb08cd24dea1986747ad..4fc9bf1fdd5d4592ec20cb944fa895bbcf443312 100644 (file)
@@ -3433,6 +3433,11 @@ bool Sema::ShouldDeleteDefaultConstructor(CXXConstructorDecl *CD) {
         // This is technically non-conformant, but sanity demands it.
         continue;
       }
+    } else if (!Union && FieldType.isConstQualified()) {
+      // -- any non-variant non-static data member of const-qualified type (or
+      //    array thereof) with no brace-or-equal-initializer does not have a
+      //    user-provided default constructor
+      return true;
     }
 
     InitializedEntity MemberEntity =
index 10520fb8bba460531e4847db412a41b04993df72..dfe0f46ea25505520ab0e4b1f289ce87feb11b51 100644 (file)
@@ -1,12 +1,11 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
 
-struct A { // expected-error {{implicit default constructor for 'A' must explicitly initialize the const member 'i'}} \
-  // expected-warning{{struct 'A' does not declare any constructor to initialize its non-modifiable members}}
-     const int i;      // expected-note {{declared here}} \
-  // expected-note{{const member 'i' will never be initialized}}
+struct A { //expected-note {{marked deleted here}} \
+     // expected-warning {{does not declare any constructor to initialize}}
+     const int i; // expected-note{{const member 'i' will never be initialized}}
      virtual void f() { } 
 };
 
 int main () {
-      (void)A(); // expected-note {{first required here}}
+      (void)A(); // expected-error {{call to deleted constructor}}
 }