[LLVMbugs] [Bug 15129] New: _Pragma operator handled too late

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 30 14:38:04 PST 2013


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

             Bug #: 15129
           Summary: _Pragma operator handled too late
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Per C11 6.10.3.4/3, _Pragma operators are handled during rescan of an expanded
macro body. Therefore, this should work:

  #define true \
    _Pragma("clang diagnostic push") \
    _Pragma("clang diagnostic ignored \"-Wdisabled-macro-expansion\"") \
    true \
    _Pragma("clang diagnostic pop")

  #define CAT2(x,y) x##y
  #define CAT(x,y) CAT2(x,y)
  int untrue = 0;
  int x = CAT(un, true);

... because the pragma should take effect during the rescan of the
expansion of 'true', and per 6.10.9/1 the tokens should be removed before we
perform the token paste.


This should give 'const char *p = "xyzzy";' and no warning.

  #define foo _Pragma("GCC diagnostic ignored \"-Wuninitialized\"") xyzzy
  #define str(x) #x
  #define STR(x) str(x)
  const char *p = STR(foo);
  int n() { int k; return k; }

Clang gets both of these wrong.

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