[cfe-commits] r73833 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDeclCXX.cpp test/SemaCXX/default-constructor-initializers.cpp test/SemaCXX/default-contructor-initializers.cpp

Fariborz Jahanian fjahanian at apple.com
Sat Jun 20 13:23:39 PDT 2009


Author: fjahanian
Date: Sat Jun 20 15:23:38 2009
New Revision: 73833

URL: http://llvm.org/viewvc/llvm-project?rev=73833&view=rev
Log:
Made improvements in c++'s object model patch on Doug's review.


Added:
    cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
Removed:
    cfe/trunk/test/SemaCXX/default-contructor-initializers.cpp
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=73833&r1=73832&r2=73833&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jun 20 15:23:38 2009
@@ -580,13 +580,13 @@
   "default arguments can only be specified for parameters in a function "
   "declaration">;
 def err_defining_default_ctor : Error<
-  "cannot define the default constructor for %0, because %1 does not "
-  "have any default constructor">;
-def not_previous_class_decl : Note<
-  "class %0 declared here">;
+  "cannot define the default constructor for %0, because %select{base class|member}1 "
+  "%2 does not have any implicit default constructor">;
+def note_previous_class_decl : Note<
+  "%0 declared here">;
 def err_unintialized_member : Error<
-  "cannot define the default constructor for %0, because of "
-  "unintialized %select{reference|const}1 member">;
+  "cannot define the implicit default constructor for %0, because "
+  "%select{reference|const}1 member %2 cannot be default-initialized">;
 
 def err_use_of_default_argument_to_function_declared_later : Error<
   "use of default argument to function %0 that is declared later in class %1">;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=73833&r1=73832&r2=73833&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sat Jun 20 15:23:38 2009
@@ -1866,9 +1866,10 @@
       }
       else {
         Diag(CurrentLocation, diag::err_defining_default_ctor) 
-          << ClassDecl->getNameAsCString() << BaseClassDecl->getNameAsCString();
-        Diag(BaseClassDecl->getLocation(), diag::not_previous_class_decl) 
-              << BaseClassDecl->getNameAsCString();
+          << Context.getTagDeclType(ClassDecl) << 1 
+          << Context.getTagDeclType(BaseClassDecl);
+        Diag(BaseClassDecl->getLocation(), diag::note_previous_class_decl) 
+              << Context.getTagDeclType(BaseClassDecl);
         err = true;
       }
     }
@@ -1890,22 +1891,22 @@
         }
         else {
           Diag(CurrentLocation, diag::err_defining_default_ctor) 
-          << ClassDecl->getNameAsCString() << 
-              FieldClassDecl->getNameAsCString();
-          Diag(FieldClassDecl->getLocation(), diag::not_previous_class_decl) 
-          << FieldClassDecl->getNameAsCString();
+          << Context.getTagDeclType(ClassDecl) << 0 <<
+              Context.getTagDeclType(FieldClassDecl);
+          Diag(FieldClassDecl->getLocation(), diag::note_previous_class_decl) 
+          << Context.getTagDeclType(FieldClassDecl);
           err = true;
         }
       }
     else if (FieldType->isReferenceType()) {
       Diag(CurrentLocation, diag::err_unintialized_member) 
-        << ClassDecl->getNameAsCString() << 0;
+        << Context.getTagDeclType(ClassDecl) << 0 << (*Field)->getNameAsCString();
       Diag((*Field)->getLocation(), diag::note_declared_at);
       err = true;
     }
     else if (FieldType.isConstQualified()) {
       Diag(CurrentLocation, diag::err_unintialized_member) 
-        << ClassDecl->getNameAsCString() << 1;
+        << Context.getTagDeclType(ClassDecl) << 1 << (*Field)->getNameAsCString();
        Diag((*Field)->getLocation(), diag::note_declared_at);
       err = true;
     }

Added: cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp?rev=73833&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp (added)
+++ cfe/trunk/test/SemaCXX/default-constructor-initializers.cpp Sat Jun 20 15:23:38 2009
@@ -0,0 +1,56 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+struct X1 { // has no implicit default constructor
+   X1(int);
+};
+
+struct X2  : X1 {  // expected-note {{'struct X2' declared here}} \
+                  //  expected-note {{'struct X2' declared here}}
+   X2(int);
+};
+
+struct X3 : public X2 {
+};
+X3 x3;  // expected-error {{cannot define the default constructor for 'struct X3', because member 'struct X2' does not have any implicit default constructor}}
+
+
+struct X4 {
+  X2 x2; 
+  X2 & rx2; // expected-note {{declared at}}
+};
+
+X4 x4; // expected-error {{cannot define the default constructor for 'struct X4', because base class 'struct X2' does not have any implicit default constructor}} \
+       // expected-error {{cannot define the implicit default constructor for 'struct X4', because reference member rx2 cannot be default-initialized}}
+
+
+struct Y1 { // has no implicit default constructor
+   Y1(int);
+};
+
+struct Y2  : Y1 { 
+   Y2(int);
+   Y2();
+};
+
+struct Y3 : public Y2 {
+};
+Y3 y3; 
+
+struct Y4 {
+  Y2 y2; 
+};
+
+Y4 y4;
+
+// More tests
+
+
+struct Z1 {
+        int& z; // expected-note {{declared at}}
+  	const int c1; // expected-note {{declared at}}
+  	volatile int v1;
+};
+
+Z1 z1;  // expected-error {{cannot define the implicit default constructor for 'struct Z1', because reference member z cannot be default-initialized}} \
+        // expected-error {{cannot define the implicit default constructor for 'struct Z1', because const member c1 cannot be default-initialized}}
+

Removed: cfe/trunk/test/SemaCXX/default-contructor-initializers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/default-contructor-initializers.cpp?rev=73832&view=auto

==============================================================================
--- cfe/trunk/test/SemaCXX/default-contructor-initializers.cpp (original)
+++ cfe/trunk/test/SemaCXX/default-contructor-initializers.cpp (removed)
@@ -1,56 +0,0 @@
-// RUN: clang-cc -fsyntax-only -verify %s
-
-struct X1 { // has no implicit default constructor
-   X1(int);
-};
-
-struct X2  : X1 {  // expected-note {{class X2 declared here}} \
-                  //  expected-note {{class X2 declared here}}
-   X2(int);
-};
-
-struct X3 : public X2 {
-};
-X3 x3;  // expected-error {{cannot define the default constructor for X3, because X2 does not have any default constructor}}
-
-
-struct X4 {
-  X2 x2; 
-  X2 & rx2; // expected-note {{declared at}}
-};
-
-X4 x4; // expected-error {{cannot define the default constructor for X4, because X2 does not have any default constructor}} \
-       // expected-error {{cannot define the default constructor for X4, because of unintialized reference member}}
-
-
-struct Y1 { // has no implicit default constructor
-   Y1(int);
-};
-
-struct Y2  : Y1 { 
-   Y2(int);
-   Y2();
-};
-
-struct Y3 : public Y2 {
-};
-Y3 y3; 
-
-struct Y4 {
-  Y2 y2; 
-};
-
-Y4 y4;
-
-// More tests
-
-
-struct Z1 {
-        int& z; // expected-note {{declared at}}
-  	const int c1; // expected-note {{declared at}}
-  	volatile int v1;
-};
-
-Z1 z1;  // expected-error {{cannot define the default constructor for Z1, because of unintialized const member}} \
-        // expected-error {{cannot define the default constructor for Z1, because of unintialized reference member}}
-





More information about the cfe-commits mailing list