[clang] [clang] Implement CWG1878 "`operator auto` template" (PR #78103)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 14 09:56:02 PST 2024


================
@@ -11322,9 +11322,22 @@ Decl *Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
       << ClassType << ConvType;
   }
 
-  if (FunctionTemplateDecl *ConversionTemplate
-                                = Conversion->getDescribedFunctionTemplate())
+  if (FunctionTemplateDecl *ConversionTemplate =
+          Conversion->getDescribedFunctionTemplate()) {
+    if (ConvType->isUndeducedAutoType()) {
+      Diag(Conversion->getTypeSpecStartLoc(), diag::err_auto_not_allowed)
+          << Conversion->getTypeSourceInfo()
+                 ->getTypeLoc()
+                 .getContainedAutoTypeLoc()
----------------
Endilll wrote:

I went this way mostly because I didn't want `const` qualifier on the member function to be highlighted, as it's not relevant. But it's getting a bit worse than this if we go your way:
```
    4 |   operator const auto() const { return 1.2; }     // error: conversion function template
      |                  ^~~~~~~~~~~~
    6 |   operator decltype(auto)() const { return 1.2; }     // error: conversion function template
      |            ^~~~~~~~~~~~~~~~~~~~~~
```

https://github.com/llvm/llvm-project/pull/78103


More information about the cfe-commits mailing list