[cfe-commits] r112581 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/CXX/dcl.decl/dcl.init/p5.cpp

Chandler Carruth chandlerc at gmail.com
Mon Aug 30 22:42:40 PDT 2010


Author: chandlerc
Date: Tue Aug 31 00:42:40 2010
New Revision: 112581

URL: http://llvm.org/viewvc/llvm-project?rev=112581&view=rev
Log:
Fix a regression that allowed clearly ill formed code. The diagnostic is still
terrible, FIXME left to do a proper job of diagnosing this.

Added:
    cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp
Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=112581&r1=112580&r2=112581&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Aug 31 00:42:40 2010
@@ -6135,6 +6135,8 @@
       CXXRecord->setPOD(false);
     if (!ZeroWidth)
       CXXRecord->setEmpty(false);
+    if (T->isReferenceType())
+      CXXRecord->setHasTrivialConstructor(false);
 
     if (const RecordType *RT = EltTy->getAs<RecordType>()) {
       CXXRecordDecl* RDecl = cast<CXXRecordDecl>(RT->getDecl());

Added: cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp?rev=112581&view=auto
==============================================================================
--- cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp (added)
+++ cfe/trunk/test/CXX/dcl.decl/dcl.init/p5.cpp Tue Aug 31 00:42:40 2010
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// FIXME: Very incomplete!
+
+//   A program that calls for default-initialization or value-initialization of
+//   an entity of reference type is illformed. If T is a cv-qualified type, the
+//   cv-unqualified version of T is used for these definitions of
+//   zero-initialization, default-initialization, and value-initialization.
+//
+// FIXME: The diagnostics for these errors are terrible because they fall out
+// of the AST representation rather than being explicitly issued during the
+// respective initialization forms.
+struct S { // expected-error {{implicit default constructor for 'S' must explicitly initialize the reference member}} \
+           // expected-note {{candidate constructor (the implicit copy constructor) not viable}}
+  int& x; // expected-note {{declared here}}
+};
+S s; // expected-note {{implicit default constructor for 'S' first required here}}
+S f() {
+  return S(); // expected-error {{no matching constructor for initialization of 'S'}}
+}





More information about the cfe-commits mailing list