[PATCH] D57540: [C++17] Don't crash while diagnosing different access specifier of a deduction guide.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 4 05:56:29 PST 2019


aaron.ballman added inline comments.


================
Comment at: test/SemaCXX/cxx1z-class-template-argument-deduction.cpp:360-361
+  struct Type {
+    Typo(); // expected-error{{deduction guide must be declared in the same scope}}
+    // expected-error at -1{{deduction guide declaration without trailing return type}}
+  };
----------------
Rakete1111 wrote:
> aaron.ballman wrote:
> > These errors are pretty unfortunate -- they don't really help the user to understand what's gone wrong here. They're an improvement over the crash, but I think we should try to make the errors more useful if we can.
> > 
> > Why is `Typo()` being treated as a deduction guide? Perhaps we could look to see if there is a `->` before making that determination?
> > Perhaps we could look to see if there is a -> before making that determination?
> 
> Yes that would be possible. The diagnostic would change for the following code:
> 
> ```
> template <typename>
> struct Foo {};
> 
> Foo();// -> Foo<int>; 
> // currently: deduction guide missing ->
> // after: C++ requires type specifier for every declaration
> ```
> 
> Is that acceptable? Or I guess I could restrict this to partial deduction guides in classes.
I think the original diagnostic is better in that case. If you restrict to partial deduction guides, do we get all the good diagnostics?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57540/new/

https://reviews.llvm.org/D57540





More information about the cfe-commits mailing list