summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaExpr.cpp7
-rw-r--r--clang/test/SemaCXX/undefined-internal.cpp21
2 files changed, 26 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 84baa7d9852..e7d167ed387 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9336,9 +9336,12 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
}
}
- // Keep track of used but undefined variables.
+ // Keep track of used but undefined variables. We make a hole in
+ // the warning for static const data members with in-line
+ // initializers.
if (Var->hasDefinition() == VarDecl::DeclarationOnly
- && Var->getLinkage() != ExternalLinkage) {
+ && Var->getLinkage() != ExternalLinkage
+ && !(Var->isStaticDataMember() && Var->hasInit())) {
SourceLocation &old = UndefinedInternals[Var->getCanonicalDecl()];
if (old.isInvalid()) old = Loc;
}
diff --git a/clang/test/SemaCXX/undefined-internal.cpp b/clang/test/SemaCXX/undefined-internal.cpp
index bb87ce0f126..a7e92499657 100644
--- a/clang/test/SemaCXX/undefined-internal.cpp
+++ b/clang/test/SemaCXX/undefined-internal.cpp
@@ -84,3 +84,24 @@ namespace test5 {
B<A>::foo(); // expected-note {{used here}}
}
}
+
+namespace test6 {
+ template <class T> struct A {
+ static const int zero = 0;
+ static const int one = 1;
+ static const int two = 2;
+
+ int value;
+
+ A() : value(zero) {
+ value = one;
+ }
+ };
+
+ namespace { struct Internal; }
+
+ void test() {
+ A<Internal> a;
+ a.value = A<Internal>::two;
+ }
+}
OpenPOWER on IntegriCloud