[llvm-bugs] [Bug 28046] New: missing default argument promotion

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 7 21:48:47 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28046

            Bug ID: 28046
           Summary: missing default argument promotion
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: vries at gcc.gnu.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Consider test.c, compiled with -std=c99:
...
extern void foo();

void bar() {
  foo(1, 2);
}

void foo(d, e)
     int d;
     unsigned int e;
{}

void bar2() {
  foo(3, 4);
}
...

With -ast-dump we get:
...
|-FunctionDecl 0xb90bd38 <test.c:62:1, col:17> col:13 used foo 'void ()' extern
|-FunctionDecl 0xb957990 <line:64:1, line:66:1> line:64:6 bar 'void ()'
| `-CompoundStmt 0xb957b30 <col:12, line:66:1>
|   `-CallExpr 0xb957af0 <line:65:3, col:11> 'void'
|     |-ImplicitCastExpr 0xb957ad8 <col:3> 'void (*)()'
<FunctionToPointerDecay>
|     | `-DeclRefExpr 0xb957a48 <col:3> 'void ()' Function 0xb90bd38 'foo'
'void ()'
|     |-IntegerLiteral 0xb957a70 <col:7> 'int' 1
|     `-IntegerLiteral 0xb957a90 <col:10> 'int' 2
|-FunctionDecl 0xb957ca0 prev 0xb90bd38 <line:68:1, line:71:2> line:68:6 used
foo 'void (int, unsigned int)'
| |-ParmVarDecl 0xb957b60 <line:69:6, col:10> col:10 d 'int'
| |-ParmVarDecl 0xb957bd0 <line:70:6, col:19> col:19 e 'unsigned int'
| `-CompoundStmt 0xb957d68 <line:71:1, col:2>
`-FunctionDecl 0xb957da0 <line:73:1, line:75:1> line:73:6 bar2 'void ()'
  `-CompoundStmt 0xb957f30 <col:13, line:75:1>
    `-CallExpr 0xb957ed8 <line:74:3, col:11> 'void'
      |-ImplicitCastExpr 0xb957ec0 <col:3> 'void (*)()'
<FunctionToPointerDecay>
      | `-DeclRefExpr 0xb957e58 <col:3> 'void ()' Function 0xb957ca0 'foo'
'void (int, unsigned int)'
      |-IntegerLiteral 0xb957e80 <col:7> 'int' 3
      `-ImplicitCastExpr 0xb957f18 <col:10> 'unsigned int' <IntegralCast>
        `-IntegerLiteral 0xb957ea0 <col:10> 'int' 4
...

The cast to unsigned int for argument 4 is not standard-compliant. Foo is a
function without prototype, so the arguments get default argument promotion,
which implies that the type of the argument should be int rather than unsigned
int.

-- 
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/20160608/1690c139/attachment.html>


More information about the llvm-bugs mailing list