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

           Summary: Clang expands the same macro differently depending on
                    its identifier
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: NetBSD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: preprocessor
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


I submitted this before, but it was abruptly closed with "resubmit". 
Anyway...last time.

Observe the output of -E for the following; both lines output should be the
same:

#define f(x) h(x
#define for(x) h(x    // for is the same macro as f .....
#define h(x) x(void) 
extern int f(f));
extern int for(for)); // but it exapnds differently....

The problem is rooted in Clang's representation of "is this token an
identifier?".  It is tempting to answer that question by testing the token
type, because this is the correct decision for all token types but identifiers.

Identifiers are treated differently and the correct test for identifiers is
only to test for identifier info being non-null (I believe).

This non-obvious situation led to this bug; which I noticed perusing the source
code (rather than dreaming up obscene tests, in case the reader wondered).

I suggest all of CPP is audited for this mistake, assuming this design decision
(efficiency perhaps?) is still deemed the right one.


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