llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.06k stars 11.59k forks source link

GNU attributes on RHS of alias declaration are silently discarded #18040

Open llvmbot opened 10 years ago

llvmbot commented 10 years ago
Bugzilla Link 17666
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @zygoloid

Extended Description

The current trunk version of clang in C++11 mode reports an error for the second static assert in the following sample (but not for the equivalent first one) and crashes for the T3 typedef.

int main() { typedef int attribute((aligned(1))) T1; // no error static_assert(alignof(T1) == 1, "wrong alignment");

constexpr int A = 1;

using T2 = int attribute((aligned(A))); static_assert(alignof(T2) == 1, "wrong alignment"); // error

typedef int attribute((aligned(A))) T3; // crash static_assert(alignof(T3) == 1, "wrong alignment"); }

ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 10 years ago

We still issue a bogus error for the second example.

llvmbot commented 10 years ago

closing per comment 1.

ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 10 years ago

Crash fixed in r193295.

Endilll commented 1 year ago

Error is still issued as of post-17 trunk: https://godbolt.org/z/ocf5cMKGe

<source>:8:17: error: static assertion failed due to requirement 'alignof(int) == 1': wrong alignment
    8 |   static_assert(alignof(T2) == 1, "wrong alignment"); // error
      |                 ^~~~~~~~~~~~~~~~
<source>:8:29: note: expression evaluates to '4 == 1'
    8 |   static_assert(alignof(T2) == 1, "wrong alignment"); // error
      |                 ~~~~~~~~~~~~^~~~
1 error generated.