[cfe-commits] r140452 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/MicrosoftCompatibility.cpp

Francois Pichet pichet2000 at gmail.com
Sat Sep 24 03:38:05 PDT 2011


Author: fpichet
Date: Sat Sep 24 05:38:05 2011
New Revision: 140452

URL: http://llvm.org/viewvc/llvm-project?rev=140452&view=rev
Log:
[microsoft] In Microsoft mode, if we are inside a template class member function and we can't resolve an identifier then assume the identifier is type dependent. The goal is to postpone name lookup to instantiation time to be able to search into type dependent base classes.

This fixes a few errors when parsing MFC code with clang.
BTW clang trunk is now about 5 patches away to be able the parse the default wizard-generated MFC project.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=140452&r1=140451&r2=140452&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Sep 24 05:38:05 2011
@@ -1690,6 +1690,16 @@
     // If this name wasn't predeclared and if this is not a function
     // call, diagnose the problem.
     if (R.empty()) {
+
+      // In Microsoft mode, if we are inside a template class member function
+      // and we can't resolve an identifier then assume the identifier is type
+      // dependent. The goal is to postpone name lookup to instantiation time 
+      // to be able to search into type dependent base classes.
+      if (getLangOptions().MicrosoftMode && CurContext->isDependentContext() &&
+          isa<CXXMethodDecl>(CurContext))
+        return ActOnDependentIdExpression(SS, NameInfo, IsAddressOfOperand,
+                                          TemplateArgs);
+
       if (DiagnoseEmptyLookup(S, SS, R, CTC_Unknown))
         return ExprError();
 

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=140452&r1=140451&r2=140452&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Sat Sep 24 05:38:05 2011
@@ -134,3 +134,25 @@
 template void function_missing_typename<D>();
 
 }
+
+
+
+namespace lookup_dependent_bases_id_expr {
+
+template<class T> class A {
+public:
+  int var;
+};
+
+
+template<class T>
+class B : public A<T> {
+public:
+  void f() {
+    var = 3;
+  }
+};
+
+template class B<int>;
+
+}
\ No newline at end of file





More information about the cfe-commits mailing list