diff options
author | Alex Lorenz <arphaman@gmail.com> | 2016-10-12 09:36:35 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2016-10-12 09:36:35 +0000 |
commit | 757a69b76017994e9f049c70c42a88f07ff15917 (patch) | |
tree | bea63e67734588eec7d670da3cf3a9034d4e553a /clang/test/SemaCXX/attr-gnu.cpp | |
parent | 883cc25d9f251165ea99556cd8234d2711eb9052 (diff) | |
download | bcm5719-llvm-757a69b76017994e9f049c70c42a88f07ff15917.tar.gz bcm5719-llvm-757a69b76017994e9f049c70c42a88f07ff15917.zip |
[Sema] Handle transparent_union attributes in C mode only
This commit marks the transparent_union attributes as C only because clang
doesn't support them in C++ mode. Prior to this commit, clang still tried to
verify these attributes in C++, leading to crashes when analyzing templated
transparent_union unions that have dependent field types. This commit ensures
that such crashes won't happen again.
As a result of this commit clang now displays a warning every time it encounters
a transparent_union attribute in C++ mode.
Differential Revision: https://reviews.llvm.org/D25308
llvm-svn: 283995
Diffstat (limited to 'clang/test/SemaCXX/attr-gnu.cpp')
-rw-r--r-- | clang/test/SemaCXX/attr-gnu.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/attr-gnu.cpp b/clang/test/SemaCXX/attr-gnu.cpp index b4e9f4609f6..a553f0d2100 100644 --- a/clang/test/SemaCXX/attr-gnu.cpp +++ b/clang/test/SemaCXX/attr-gnu.cpp @@ -27,3 +27,19 @@ public: void test3() __attribute__((cf_unknown_transfer)) override {} // Ok, not known to GCC. }; } + +template<typename T> +union Tu { T b; } __attribute__((transparent_union)); // expected-warning {{'transparent_union' attribute ignored}} + +template<typename T> +union Tu2 { int x; T b; } __attribute__((transparent_union)); // expected-warning {{'transparent_union' attribute ignored}} + +union Tu3 { int x; } __attribute((transparent_union)); // expected-warning {{'transparent_union' attribute ignored}} + +void tuTest1(Tu<int> u); // expected-note {{candidate function not viable: no known conversion from 'int' to 'Tu<int>' for 1st argument}} +void tuTest2(Tu3 u); // expected-note {{candidate function not viable: no known conversion from 'int' to 'Tu3' for 1st argument}} +void tu() { + int x = 2; + tuTest1(x); // expected-error {{no matching function for call to 'tuTest1'}} + tuTest2(x); // expected-error {{no matching function for call to 'tuTest2'}} +} |