[PATCH] D25719: [Sema] Fix PR30664

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 27 00:16:12 PDT 2016


rsmith added inline comments.


================
Comment at: lib/Sema/SemaExprCXX.cpp:3429-3430
           // initial standard conversion sequence converts the source type to
-          // the type required by the argument of the constructor
-          BeforeToType = Ctor->getParamDecl(0)->getType().getNonReferenceType();
+          // the type required by the argument of the constructor or the 'void'
+          // type if the argument has no constructors.
+          BeforeToType =
----------------
I think you mean "if the constructor has no parameters", right?


================
Comment at: lib/Sema/SemaExprCXX.cpp:3433
+              Ctor->param_empty()
+                  ? Context.VoidTy
+                  : Ctor->getParamDecl(0)->getType().getNonReferenceType();
----------------
It looks like this will result in us building an expression like `T(void({}))`. That would be invalid, and we shouldn't have it in the AST. Instead, we should probably build `T{}` for this case.


================
Comment at: test/SemaCXX/cxx11-crashes.cpp:109
+    const outer &o;    // expected-note {{reference member declared here}}
+    inner() : o({}) {} // expected-warning {{binding reference member 'o' to a temporary value}}
+  };
----------------
This case is ill-formed under http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1696

Is there any way to tickle this problem without binding a class member to a temporary? If not, I'd prefer we instead implement DR1696 to eliminate the problem.


Repository:
  rL LLVM

https://reviews.llvm.org/D25719





More information about the cfe-commits mailing list