[LLVMbugs] [Bug 12504] New: Array type qualifiers only allowed in function parameters

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 9 10:03:11 PDT 2012


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

             Bug #: 12504
           Summary: Array type qualifiers only allowed in function
                    parameters
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: grosser at fim.uni-passau.de
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Following the C standard:

=============================
6.7.5.2 Array declarators 

Constraints

In addition to optional type qualifiers and the keyword static, the [ and ] may
delimit an expression or *. If they delimit an expression (which specifies the
size of an array), the expression shall have an integer type. If the expression
is a constant expression, it shall have a value greater than zero. The element
type shall not be an incomplete or function type. The optional type qualifiers
and the keyword static shall appear only in a declaration of a function
parameter with an array type, and then only in the outermost array type
derivation.
=============================

I am allowed to use static/restrict in a function parameter but not within a
function:

========================
void f_restrict(float A[restrict 10]) { // valid
        float B[restrict 10];           // invalid
}
void f_static(float A[static 10]) {     // valid
        float B[static 10];             // invalid
}
========================

gcc gets it right (icc too):

gcc /tmp/test.c -c -std=gnu99
/tmp/test.c: In function ‘f_restrict’:
/tmp/test.c:2:8: error: static or type qualifiers in non-parameter array
declarator
/tmp/test.c: In function ‘f_static’:
/tmp/test.c:5:8: error: static or type qualifiers in non-parameter array
declarator

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