[cfe-commits] r139253 - in /cfe/trunk: lib/Parse/ParseStmt.cpp test/SemaCXX/member-init.cpp

Douglas Gregor dgregor at apple.com
Wed Sep 7 13:36:12 PDT 2011


Author: dgregor
Date: Wed Sep  7 15:36:12 2011
New Revision: 139253

URL: http://llvm.org/viewvc/llvm-project?rev=139253&view=rev
Log:
When parsing a function-try-block that does not have a
ctor-initializer, remember to call the Sema action to generate default
ctor-initializers. What a delightful little miscompile. Fixes PR10578
/ <rdar://problem/9877267>.

Modified:
    cfe/trunk/lib/Parse/ParseStmt.cpp
    cfe/trunk/test/SemaCXX/member-init.cpp

Modified: cfe/trunk/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseStmt.cpp?rev=139253&r1=139252&r2=139253&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/lib/Parse/ParseStmt.cpp Wed Sep  7 15:36:12 2011
@@ -1856,7 +1856,9 @@
   // Constructor initializer list?
   if (Tok.is(tok::colon))
     ParseConstructorInitializer(Decl);
-
+  else
+    Actions.ActOnDefaultCtorInitializers(Decl);
+  
   if (PP.isCodeCompletionEnabled()) {
     if (trySkippingFunctionBodyForCodeCompletion()) {
       BodyScope.Exit();

Modified: cfe/trunk/test/SemaCXX/member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-init.cpp?rev=139253&r1=139252&r2=139253&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-init.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-init.cpp Wed Sep  7 15:36:12 2011
@@ -52,3 +52,21 @@
 struct TypedefInit {
   typedef int A = 0; // expected-error {{illegal initializer}}
 };
+
+// PR10578 / <rdar://problem/9877267>
+namespace PR10578 {
+  template<typename T>
+  struct X { 
+    X() {
+      T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+    }
+  };
+
+  struct Y : X<int> {
+    Y();
+  };
+
+  Y::Y() try { // expected-note{{in instantiation of member function 'PR10578::X<int>::X' requested here}}
+  } catch(...) {
+  }
+}





More information about the cfe-commits mailing list