]> granicus.if.org Git - clang/commitdiff
Revert "Fix the undefined-but-used odr-use marker (DR48)"
authorAlp Toker <alp@nuanti.com>
Sun, 1 Jun 2014 19:13:44 +0000 (19:13 +0000)
committerAlp Toker <alp@nuanti.com>
Sun, 1 Jun 2014 19:13:44 +0000 (19:13 +0000)
Wrong patch got committed (this one isn't ready for prime time).

This reverts commit r209996.

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

include/clang/Sema/SemaInternal.h
test/CXX/drs/dr0xx.cpp
test/SemaCXX/undefined-internal.cpp

index 59c84517a7d47e10c91b45c615b82341d099dd5c..4ee10478e487bf2ffbc87691f26e249a3ae79eb1 100644 (file)
@@ -58,8 +58,10 @@ inline void MarkVarDeclODRUsed(VarDecl *Var,
     SourceLocation Loc, Sema &SemaRef,
     const unsigned *const FunctionScopeIndexToStopAt) {
   // Keep track of used but undefined variables.
-  if (Var->hasDefinition(SemaRef.Context) != VarDecl::Definition &&
-      !Var->isExternallyVisible()) {
+  // FIXME: We shouldn't suppress this warning for static data members.
+  if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
+    !Var->isExternallyVisible() &&
+    !(Var->isStaticDataMember() && Var->hasInit())) {
       SourceLocation &old = SemaRef.UndefinedButUsed[Var->getCanonicalDecl()];
       if (old.isInvalid()) old = Loc;
   }
index 64b85a81d99744c0dda7ba25577918dcde4a4af0..29e1720b1bbf07e26f6f69483107c5c829373176 100644 (file)
@@ -507,13 +507,14 @@ namespace dr48 { // dr48: yes
   namespace {
     struct S {
       static const int m = 0;
-      // FIXME: This diagnostic is working but gets suppressed due to other errors in the TU.
-      static const int n = 0; // FIXME-expected-warning {{has internal linkage but is not defined}}
+      static const int n = 0;
       static const int o = 0;
     };
   }
   int a = S::m;
-  const int &b = S::n; // FIXME-expected-note {{used here}}
+  // FIXME: We should produce a 'has internal linkage but is not defined'
+  // diagnostic for 'S::n'.
+  const int &b = S::n;
   const int S::o;
   const int &c = S::o;
 }
index 7f81ac9feba22db87a3599d3a1f9346d4bf9a8f9..1cb0708a5320af92945dd423cdb3a5c800f3fb27 100644 (file)
@@ -137,12 +137,15 @@ namespace cxx11_odr_rules {
   //
   // Note that the warning in question can trigger in cases some people would
   // consider false positives; hopefully that happens rarely in practice.
+  //
+  // FIXME: Suppressing this test while I figure out how to fix a bug in the
+  // odr-use marking code.
 
   namespace {
     struct A {
       static const int unused = 10;
-      static const int used1 = 20; // expected-warning {{internal linkage}}
-      static const int used2 = 20; // expected-warning {{internal linkage}}
+      static const int used1 = 20; // xpected-warning {{internal linkage}}
+      static const int used2 = 20; // xpected-warning {{internal linkage}}
       virtual ~A() {}
     };
   }
@@ -163,10 +166,10 @@ namespace cxx11_odr_rules {
 
     // Check that the checks work with unevaluated contexts
     (void)sizeof(p(A::used1));
-    (void)typeid(p(A::used1)); // expected-note {{used here}}
+    (void)typeid(p(A::used1)); // xpected-note {{used here}}
 
     // Misc other testing
-    a(A::unused, 1 ? A::used2 : A::used2); // expected-note {{used here}}
+    a(A::unused, 1 ? A::used2 : A::used2); // xpected-note {{used here}}
     b();
   }
 }