[cfe-commits] r102436 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/SemaCXX/warn-unused-variables.cpp

Douglas Gregor dgregor at apple.com
Tue Apr 27 09:20:13 PDT 2010


Author: dgregor
Date: Tue Apr 27 11:20:13 2010
New Revision: 102436

URL: http://llvm.org/viewvc/llvm-project?rev=102436&view=rev
Log:
Don't look into incomplete types when trying to warn about unused
variables. Fixes PR6948.

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaCXX/warn-unused-variables.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=102436&r1=102435&r2=102436&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 27 11:20:13 2010
@@ -543,6 +543,11 @@
         return false;
     }
 
+    // If we failed to complete the type for some reason, don't
+    // diagnose the variable.
+    if (Ty->isIncompleteType())
+      return false;
+
     if (const TagType *TT = Ty->getAs<TagType>()) {
       const TagDecl *Tag = TT->getDecl();
       if (Tag->hasAttr<UnusedAttr>())

Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=102436&r1=102435&r2=102436&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Tue Apr 27 11:20:13 2010
@@ -51,3 +51,11 @@
   X0<int> i(p);
   (void)i;
 }
+
+namespace PR6948 {
+  template<typename T> class X;
+  
+  void f() {
+    X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
+  }
+}





More information about the cfe-commits mailing list