]> granicus.if.org Git - clang/commitdiff
Implicit decl ref expressions might not have name locations; don't silently
authorJohn McCall <rjmccall@apple.com>
Tue, 17 Aug 2010 21:27:17 +0000 (21:27 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 17 Aug 2010 21:27:17 +0000 (21:27 +0000)
fail to instantiate them.

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

lib/Sema/TreeTransform.h
test/SemaTemplate/instantiate-declref.cpp

index 2f8d075c2ac4eac2d574f57c38970ac9d6737b6b..fc6c7f08e09aedbf90279c9a9b594edc98294a0a 100644 (file)
@@ -4214,10 +4214,12 @@ TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
   if (!ND)
     return SemaRef.ExprError();
 
-  DeclarationNameInfo NameInfo
-    = getDerived().TransformDeclarationNameInfo(E->getNameInfo());
-  if (!NameInfo.getName())
-    return SemaRef.ExprError();
+  DeclarationNameInfo NameInfo = E->getNameInfo();
+  if (NameInfo.getName()) {
+    NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
+    if (!NameInfo.getName())
+      return SemaRef.ExprError();
+  }
 
   if (!getDerived().AlwaysRebuild() &&
       Qualifier == E->getQualifier() &&
index 2d27075bd41f40ab1afa100e2c5c87eb771c559f..ced56dfc6abc86bc272e56dccf727c6cb4e78cf4 100644 (file)
@@ -95,3 +95,13 @@ namespace test0 {
   };
   void g() { X<2>(); }
 }
+
+// <rdar://problem/8302161>
+namespace test1 {
+  template <typename T> void f(T const &t) {
+    union { char c; T t_; };
+    c = 'a'; // <- this shouldn't silently fail to instantiate
+    T::foo(); // expected-error {{has no members}}
+  }
+  template void f(int const &); // expected-note {{requested here}}
+}