[cfe-commits] r81869 - in /cfe/trunk: lib/Sema/SemaTemplateDeduction.cpp lib/Sema/SemaTemplateInstantiate.cpp test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp

Douglas Gregor dgregor at apple.com
Tue Sep 15 09:51:43 PDT 2009


Author: dgregor
Date: Tue Sep 15 11:51:42 2009
New Revision: 81869

URL: http://llvm.org/viewvc/llvm-project?rev=81869&view=rev
Log:
Slightly improved template argument deduction for use in partial
ordering, along with another test case for partial ordering of partial
specializations. 

Added:
    cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp   (with props)
Modified:
    cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=81869&r1=81868&r2=81869&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Tue Sep 15 11:51:42 2009
@@ -151,7 +151,18 @@
     return Sema::TDK_Success;
   }
 
-  // FIXME: Compare the expressions for equality!
+  if (Deduced[NTTP->getIndex()].getKind() == TemplateArgument::Expression) {
+    // Compare the expressions for equality
+    llvm::FoldingSetNodeID ID1, ID2;
+    Deduced[NTTP->getIndex()].getAsExpr()->Profile(ID1, Context, true);
+    Value->Profile(ID2, Context, true);
+    if (ID1 == ID2)
+      return Sema::TDK_Success;
+   
+    // FIXME: Fill in argument mismatch information
+    return Sema::TDK_NonDeducedMismatch;
+  }
+
   return Sema::TDK_Success;
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=81869&r1=81868&r2=81869&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Tue Sep 15 11:51:42 2009
@@ -843,6 +843,9 @@
     return true;
   }
 
+  if (ClassTemplateSpec->isInvalidDecl())
+    return true;
+  
   ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate();
   CXXRecordDecl *Pattern = 0;
 

Added: cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp?rev=81869&view=auto

==============================================================================
--- cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp (added)
+++ cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp Tue Sep 15 11:51:42 2009
@@ -0,0 +1,16 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+template<int I, int J, class T> class X { 
+  static const int value = 0;
+};
+
+template<int I, int J> class X<I, J, int> { 
+  static const int value = 1;
+};
+
+template<int I> class X<I, I, int> { 
+  static const int value = 2;
+};
+
+int array0[X<0, 0, float>::value == 0? 1 : -1];
+int array1[X<0, 1, int>::value == 1? 1 : -1];
+int array2[X<0, 0, int>::value == 2? 1 : -1];

Propchange: cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp

------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp

------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp

------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list