[LLVMbugs] [Bug 9679] New: fixits should not be issued within template instantiations

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 11 10:14:39 PDT 2011


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

           Summary: fixits should not be issued within template
                    instantiations
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


Consider the following:

template<typename T> struct SIsClass { class T::S x; };
template<typename T> struct SIsStruct { struct T::S x; };
struct ClassS { class S {}; };
struct StructS { struct S {}; };

SIsClass<ClassS> a;
SIsStruct<ClassS> b;
SIsClass<StructS> c;
SIsStruct<StructS> d;


Compiling this with -Wall generates the following:


fixit.cpp:2:51: warning: struct  'S' was previously declared as a class 
template<typename T> struct SIsStruct { struct T::S x; };
                                                  ^
                                                  class
fixit.cpp:7:19: note: in instantiation of template class 'SIsStruct<ClassS>'
requested here
SIsStruct<ClassS> b;
                  ^
fixit.cpp:3:23: note: previous use is here
struct ClassS { class S {}; };
                      ^
fixit.cpp:1:49: warning: class  'S' was previously declared as a struct 
template<typename T> struct SIsClass { class T::S x; };
                                                ^
                                                struct
fixit.cpp:8:19: note: in instantiation of template class 'SIsClass<StructS>'
requested here
SIsClass<StructS> c;
                  ^
fixit.cpp:4:25: note: previous use is here
struct StructS { struct S {}; };
                        ^
2 warnings generated.


There are two things very obviously wrong with these fixits:

1) They're suggesting the wrong change (replacing the *class name* rather than
the struct/class keyword).
2) The suggestion not sensible within a template instantiation. Applying the
fixit (if it worked) would simply move the problem to the other two
instantiations.

The first problem is specific to this fixit; the second seems to be a general
issue: problems encountered within the body of a template, while instantiating
that template, can never safely have fixits -- if the fixit were safe to apply
to all instantiations, we should have given it while parsing the template.

-- 
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.



More information about the llvm-bugs mailing list