[cfe-dev] Tooling vs -fdelayed-template-parsing WAS: Clang-cl.exe and the VC++ preprocessor

Kim Gräsman kim.grasman at gmail.com
Mon Aug 4 15:13:13 PDT 2014


Hi Reid,

On Mon, Aug 4, 2014 at 9:07 PM, Reid Kleckner <rnk at google.com> wrote:

>
>> Thanks, that explains it. I'm about to take off on a road-trip, or I'd
>> offer to add a warning. If you can give me a hint as to where to start I
>> may be able to get to it when we get back.
>>
>
> I don't know where exactly this is happening, but we typically build
> DependentDeclRefExprs when we have an undeclared id in a template in
> -fms-compatibility mode.  The name isn't actually dependent on template
> arguments, but it allows us to delay lookup until template instantiation
> time, which is basically what MSVC does.
>

I've been through this, and I believe there's a bug in that logic:
https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaCXXScopeSpec.cpp#L703

  if (DC->isDependentContext() && DC->isFunctionOrMethod()) {
      SS.Extend(Context, &Identifier, IdentifierLoc, CCLoc);
      return false;
  }

I think this should also check if it's in a class template. When we're in a
function template it makes no sense to do lookup in dependent base classes,
right?

When I short-circuit that conditional (I butchered it by adding &&
isa<CXXRecordDecl>(DC->getParent()), but that's probably wrong), I get a
diagnostic as expected:

incomplete.cpp:4:3: error: use of undeclared identifier 'UndefinedSymbol'
  UndefinedSymbol::bar(t);
  ^

That must be good, right?

- Kim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140805/62a424fa/attachment.html>


More information about the cfe-dev mailing list