[PATCH] D19479: 26748 - clang-cl fails to compile atlctrlw.h header from WTL

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 25 09:35:04 PDT 2016


rnk requested changes to this revision.
rnk added a comment.
This revision now requires changes to proceed.

We definitely should not rely on typo correction or other error recovery mechanisms to do this for us. Otherwise we can end up accepting ill-formed programs like this one:

  struct MyStruct { };
  template <typename T>
  struct A : T {
    MyStruct * f() { return new MyStructX; } // typo correction will recover to MyStruct
  };

I think the right way to do this is to form a dependent AST node like a DependentScopeDeclRefExpr. We do the same thing elsewhere under -fms-compatibility. This way, we can redo lookup at instantiation time.

The recovered AST of the test case you gave would resemble the source code `new typename CCommandBarCtrlImpl::CMsgHookMap`. By using the derived class name `CCommandBarCtrlImpl` instead of `T`, we don't have to guess which dependent base `CMsgHookMap` is coming from.


================
Comment at: lib/Sema/SemaLookup.cpp:4440
@@ -4439,3 +4439,1 @@
 
-  // In Microsoft mode, don't perform typo correction in a template member
-  // function dependent context because it interferes with the "lookup into
----------------
This is a dangerous change, and should be done as a separate change if we still want to do it. I have seen cases where typo correction and -fms-compatibility end up fighting, and I don't think they've all been fixed.


http://reviews.llvm.org/D19479





More information about the cfe-commits mailing list