sepavloff marked an inline comment as done.

================
Comment at: lib/Sema/SemaDecl.cpp:8657-8658
@@ +8656,4 @@
+  DeclContext *SemanticDC = D->getDeclContext();
+  if (SemanticDC->isDependentContext())
+    return false;
+  // Get here only for out-of-line declarations: lexical context is dependent,
----------------
rsmith wrote:
> I don't think this is right. Given:
> 
>   template<typename T> void f() {
>     extern void g();
>     extern void g();
>   }
> 
> ... we do want to link the two declarations of `g` together. We even want to 
> link them to a prior declaration of `::g` if there is one, since they have a 
> non-dependent type, otherwise we'll reject cases like:
> 
>   void g();
>   constexpr void (*p)() = g;
>   template<bool> struct X { typedef int type; };
>   template<typename T> void f() {
>     extern void g();
>     X<&g == p>::type n; // note: no 'typename' required, not value-dependent,
>   }                     // must evaluate to 'true' while parsing the template
> 
> Perhaps we're trying to make this check too general, and we should instead 
> only make this new logic apply to the case of friend declarations. Are there 
> any cases where a friend declaration in a dependent context that names a 
> non-member function needs to be added to the redeclaration chain?
It is convenient to have single function for both friend and forward 
declarations, as it is called from the point where both cases may be observed.

It looks like there is no mandatory requirement to add a friend declaration in 
a dependent context to the redeclaration chain, because ill-formed program will 
be detected during instantiation of enclosing template class. But making so 
allows to detect some problems earlier.


https://reviews.llvm.org/D16989



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to