[PATCH] D64820: [Sema] Avoids an assertion failure when an invalid conversion declaration is used

Mark de Wever via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 31 04:36:34 PDT 2019


Mordante updated this revision to Diff 218213.
Mordante added a comment.

Addresses the review remarks:

- Moved the unit test to SemaCXX (also use the PR as name of the file)
- Change the unit test to use `-verify` instead of `FileCheck`


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

https://reviews.llvm.org/D64820

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/PR31422.cpp


Index: clang/test/SemaCXX/PR31422.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/PR31422.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -verify %s
+
+// expected-error at +3 {{cannot specify any part of a return type in the declaration of a conversion function; use an alias template to declare a conversion to 'auto (Ts &&...) const'}}
+// expected-error at +2 {{conversion function cannot convert to a function type}}
+struct S {
+  template <typename... Ts> operator auto()(Ts &&... xs) const;
+};
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -8066,6 +8066,9 @@
     }
 
     SemaRef.CheckConversionDeclarator(D, R, SC);
+    if (D.isInvalidType())
+      return nullptr;
+
     IsVirtualOkay = true;
     return CXXConversionDecl::Create(
         SemaRef.Context, cast<CXXRecordDecl>(DC), D.getBeginLoc(), NameInfo, R,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64820.218213.patch
Type: text/x-patch
Size: 1023 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190831/472cb6ac/attachment.bin>


More information about the cfe-commits mailing list