http://llvm.org/bugs/show_bug.cgi?id=10168

           Summary: -Wunused gives multiple errors for unused variable in
                    template
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


template<typename T>
struct S {
  void f() {
    int a;
  }
};

int main() {
  S<int>().f();
  S<double>().f();
}


tmp.cpp:4:9: warning: unused variable 'a' [-Wunused-variable]
    int a;
        ^
tmp.cpp:4:9: warning: unused variable 'a' [-Wunused-variable]                   
tmp.cpp:9:12: note: in instantiation of member function 'S<int>::f' requested
here
  S<int>().f();
           ^
tmp.cpp:4:9: warning: unused variable 'a' [-Wunused-variable]                   
    int a;
        ^
tmp.cpp:10:15: note: in instantiation of member function 'S<double>::f'
requested here     
  S<double>().f();
              ^

One warning is produced for the template definition, and one more is produced
for each instantiation. Strangely, we don't get the first warning for a
dependently-typed unused variable.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to