[LLVMbugs] [Bug 6496] New: bad Clang diagnostics when signed/unsigned is combined with a typedef

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 4 12:36:42 PST 2010


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

           Summary: bad Clang diagnostics when signed/unsigned is combined
                    with a typedef
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P5
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: zhanyong.wan at gmail.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com


It's easy for a user to make the mistake of qualifying an integer typedef with
signed or unsigned.  Clang's error messages aren't very helpful:

$ cat t.cc
typedef int Integer;
typedef unsigned Integer UnsignedInteger;

void Test() {
  unsigned Integer foo;
  unsigned bar = (unsigned Integer)-1;
}

$ clang t.cc
t.cc:2:18: error: typedef redefinition with different types ('unsigned int' vs
'int')
typedef unsigned Integer UnsignedInteger;
                 ^
t.cc:1:13: note: previous definition is here
typedef int Integer;
            ^
t.cc:2:25: error: invalid token after top level declarator
typedef unsigned Integer UnsignedInteger;
                        ^
                        ;
t.cc:5:19: error: expected ';' at end of declaration
  unsigned Integer foo;
                  ^
                  ;
t.cc:6:28: error: expected ')'
  unsigned bar = (unsigned Integer)-1;
                           ^
t.cc:6:18: note: to match this '('
  unsigned bar = (unsigned Integer)-1;
                 ^
6 diagnostics generated.

I'd expect to see something like "'unsigned' cannot be combined with a typedef
('Integer')."

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