]> granicus.if.org Git - clang/commitdiff
[ODRHash] Hash Template and TemplateExpansion in TemplateArgument.
authorRichard Trieu <rtrieu@google.com>
Wed, 14 Jun 2017 03:17:26 +0000 (03:17 +0000)
committerRichard Trieu <rtrieu@google.com>
Wed, 14 Jun 2017 03:17:26 +0000 (03:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305361 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ODRHash.cpp
test/Modules/odr_hash.cpp

index 83355270c59a88b465a19844996be564de91b601..a1c2fbb0c4f2bb714aa7699091374a65432eb6aa 100644 (file)
@@ -150,13 +150,16 @@ void ODRHash::AddTemplateArgument(TemplateArgument TA) {
     case TemplateArgument::Declaration:
     case TemplateArgument::NullPtr:
     case TemplateArgument::Integral:
+      break;
     case TemplateArgument::Template:
     case TemplateArgument::TemplateExpansion:
+      AddTemplateName(TA.getAsTemplateOrTemplatePattern());
       break;
     case TemplateArgument::Expression:
       AddStmt(TA.getAsExpr());
       break;
     case TemplateArgument::Pack:
+      llvm_unreachable("Pack");
       break;
   }
 }
index 36f2e4bea00c62d53e6e6def17d12546ff0a90fe..51bd62697246b95a0ff3afc256531e1cfbcfdba5 100644 (file)
@@ -1051,6 +1051,24 @@ S3 s3;
 // expected-note@first.h:* {{but in 'FirstModule' found type alias 'T' with different underlying type 'U3<2>'}}
 #endif
 
+#if defined(FIRST)
+template<class> struct T4a {};
+template <template <class> class T> struct U4 {};
+struct S4 {
+  U4<T4a> x;
+};
+#elif defined(SECOND)
+template<class> struct T4b {};
+template <template <class> class T> struct U4 {};
+struct S4 {
+  U4<T4b> x;
+};
+#else
+S4 s4;
+// expected-error@first.h:* {{'TemplateArgument::S4::x' from module 'FirstModule' is not present in definition of 'TemplateArgument::S4' in module 'SecondModule'}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
+#endif
+
 }
 
 // Interesting cases that should not cause errors.  struct S should not error