================
@@ -7416,10 +7416,11 @@ NamedDecl *Sema::ActOnVariableDeclarator(
     tryToFixVariablyModifiedVarType(TInfo, R, D.getIdentifierLoc(),
                                     /*DiagID=*/0);
 
-  if (const AutoType *AutoT = R->getAs<AutoType>())
-    CheckConstrainedAuto(
-        AutoT,
-        TInfo->getTypeLoc().getContainedAutoTypeLoc().getConceptNameLoc());
+  if (const AutoType *AutoT = R->getAs<AutoType>()) {
+    AutoTypeLoc Loc = TInfo->getTypeLoc().getContainedAutoTypeLoc();
----------------
mizvekov wrote:

Sure, but let me get back first to the other problem in this area:

I think that assumption I pointed out is wrong, we should not be using 
`getAs<AutoType>` here, as that will not dig through ReferenceType and 
PointerType, and the following example will not be diagnosed: 
https://godbolt.org/z/jzEaYPq4r

The `getContainedAutoTypeLoc` is what is a good fit for that, and what we 
should be using throughout. It will dig through the things needed for finding 
the AutoType, like pointers, references, and some of the necessary type sugar 
which can appear in source code when writing a deduced type. It does not dig 
through the things it doesn't need to, like `decltype`, because you can't write 
a deduced type with that.

So something like:
```suggestion
  if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc()) {
    const AutoType *AT = TL.getTypePtr();
```

Should work, and it will not get confused by the error recovery issue, which 
can be addressed separately.

Nit: We conventionally use `TL` abbreviation for TypeLoc, and `Loc` is 
conventional for SourceLocation.

https://github.com/llvm/llvm-project/pull/98622
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to