[llvm-bugs] [Bug 50391] New: GCC Compat attribute 'mode' doesn't work on type-aliases

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 18 10:23:44 PDT 2021


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

            Bug ID: 50391
           Summary: GCC Compat attribute 'mode' doesn't work on
                    type-aliases
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: erich.keane at intel.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Low priority since 'mode' is horrible and not particularly well used.

See: https://godbolt.org/z/jGEesvWeT

typedef int __attribute__((mode(QI)))  Type;
using AliasTy = int __attribute__((mode(QI)));

template<typename T>
void foo(){}

int main() {
    foo<Type>();
    foo<AliasTy>();
    foo<int>();
}


Presumably the attribute should work the same in the typedef as the type alias,
but it doesnt.  

The assembly is:
        call    void foo<signed char>()
        call    void foo<int>()
        call    void foo<int>()
instead of the 2nd also being a signed-char.


It is just silently ignored in a type-alias entirely, even for SEMA:
https://godbolt.org/z/YP9q3o1qv

Note how we get an error for the 1st line, but not the 2nd.



typedef int __attribute__((mode(DF)))  Type;
using AliasTy = int __attribute__((mode(DF)));

template<typename T>
void foo(){}

int main() {
    foo<Type>();
    foo<AliasTy>();
    foo<int>();
}

<source>:3:28: error: type of machine mode does not match type of base type
typedef int __attribute__((mode(DF)))  Type;


We even don't bother to check the contents at all!
https://godbolt.org/z/Mrfxqzaba

-- 
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/20210518/8f2eea45/attachment.html>


More information about the llvm-bugs mailing list