instead from the Scope; Inner scopes in bodies don't have DeclContexts associated with them.
Fixes http://llvm.org/PR9160 & rdar://problem/
8966163.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125097
91177308-0d34-0410-b5e6-
96231b3b80d8
Diagnostic::Ignored)
return;
- // Don't diagnose declarations at file scope. The scope might not
- // have a DeclContext if (e.g.) we're parsing a function prototype.
- DeclContext *NewDC = static_cast<DeclContext*>(S->getEntity());
- if (NewDC && NewDC->isFileContext())
+ // Don't diagnose declarations at file scope.
+ DeclContext *NewDC = D->getDeclContext();
+ if (NewDC->isFileContext())
return;
// Only diagnose if we're shadowing an unambiguous field or variable.
double Bar = 12; // Don't warn.
}
}
+
+// http://llvm.org/PR9160
+namespace PR9160 {
+struct V {
+ V(int);
+};
+struct S {
+ V v;
+ static void m() {
+ if (1) {
+ V v(0);
+ }
+ }
+};
+}