]> granicus.if.org Git - clang/commitdiff
[microsoft] In Microsoft mode, if we are inside a template class member function...
authorFrancois Pichet <pichet2000@gmail.com>
Sat, 24 Sep 2011 10:38:05 +0000 (10:38 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Sat, 24 Sep 2011 10:38:05 +0000 (10:38 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140452 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/SemaCXX/MicrosoftCompatibility.cpp

index 31eb19e1747824731251cb47c18c5432ce286130..c06f5a7b83b3bef954511fed4f7d463402ed1afd 100644 (file)
@@ -1690,6 +1690,16 @@ ExprResult Sema::ActOnIdExpression(Scope *S,
     // 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();
 
index 788fcfbff020ab2233e85b1edf77cfdb9337fd90..1370b7dbf4f178cbf38d6b2c67a7c9c04708f620 100644 (file)
@@ -134,3 +134,25 @@ void function_missing_typename()
 template void function_missing_typename<D>();\r
 \r
 }\r
+\r
+\r
+\r
+namespace lookup_dependent_bases_id_expr {\r
+\r
+template<class T> class A {\r
+public:\r
+  int var;\r
+};\r
+\r
+\r
+template<class T>\r
+class B : public A<T> {\r
+public:\r
+  void f() {\r
+    var = 3;\r
+  }\r
+};\r
+\r
+template class B<int>;\r
+\r
+}
\ No newline at end of file