[PATCH] D19108: [Sema] Fixed assert failure in template code analyzer
Eugene via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 14 05:49:38 PDT 2016
kevgs created this revision.
kevgs added reviewers: rsmith, dblaikie.
kevgs added a subscriber: cfe-commits.
Fix for this bug https://llvm.org/bugs/show_bug.cgi?id=27312
http://reviews.llvm.org/D19108
Files:
lib/Sema/SemaAccess.cpp
test/SemaTemplate/crash-bug-27258.cpp
Index: test/SemaTemplate/crash-bug-27258.cpp
===================================================================
--- /dev/null
+++ test/SemaTemplate/crash-bug-27258.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+template <class T>
+struct AA {
+ template <T>
+ struct B {};
+};
+
+class C {
+ int i; // expected-note{{implicitly declared private here}}
+ template <class T>
+ template <T>
+ friend struct AA<T>::B;
+};
+
+struct A {
+ template <class T>
+ struct B {
+ void f() {
+ C c;
+ c.i; // expected-error{{'i' is a private member of 'C'}} expected-warning{{expression result unused}}
+ }
+ };
+};
Index: lib/Sema/SemaAccess.cpp
===================================================================
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -475,8 +475,8 @@
// If the class's context can't instantiate to the friend's
// context, it can't be a dependent match.
- if (!MightInstantiateTo(S, CTD->getDeclContext(),
- Friend->getDeclContext()))
+ if (Friend->getDeclContext()->isDependentContext() ||
+ !MightInstantiateTo(S, CTD->getDeclContext(), Friend->getDeclContext()))
continue;
// Otherwise, it's a dependent match.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19108.53693.patch
Type: text/x-patch
Size: 1253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160414/0b20701e/attachment.bin>
More information about the cfe-commits
mailing list