[LLVMbugs] [Bug 21106] New: Incorrect rendering of variable declarations specifying register allocation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Sep 30 18:04:11 PDT 2014


            Bug ID: 21106
           Summary: Incorrect rendering of variable declarations
                    specifying register allocation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: matthew.fernandez at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

[Originally posted to cfe-dev.]

GCC allows you to specify a register to use during a variable declaration
(https://gcc.gnu.org/onlinedocs/gcc/Local-Reg-Vars.html#Local-Reg-Vars). Clang
seems to understand these declarations, but does not correctly render these
when pretty printing the AST:

 $ cat foo.c
 void foo(void) {
     register int x asm("eax");
 $ clang-3.2.7 -c foo.c # compiles without error
 $ clang-3.2.7 -cc1 -ast-print foo.c
 void foo() {
     register int x;
 $ clang-r207601 -cc1 -ast-print foo.c
 void foo() {
    register int x asm("eax");

 $ cat bar.c
 void bar(void) {
     register int x asm("eax") = 1;
 $ clang-3.2.7 -c bar.c # compiles without error
 $ clang-3.2.7 -cc1 -ast-print bar.c
 void bar() {
     register int x = 1;
 $ clang-r207601 -cc1 -ast-print bar.c
 void bar() {
     register int x = 1 asm("eax");

As you can see from the above, the two Clang versions I've tested have
different behaviour, though neither seem correct. The versions generated by the
second version of Clang do not seem to be syntactically valid. I have not yet
tried with the current tip, but the two above are:
 - Debian clang version 3.2-7ubuntu1 (tags/RELEASE_32/final) (based on LLVM
 - clang version 3.5.0 (trunk 207601)

This seems to be independent of the target platform; at least I get similar
results for ARM and x86.

Renato Golin has since replicated the r207601 behaviour above at the current
Clang tip.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141001/6216a0d5/attachment.html>

More information about the llvm-bugs mailing list