mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-09 16:06:05 +00:00

Before this commit, expression statements could not be annotated with statement attributes. Whenever parser found attribute, it unconditionally assumed that it was followed by a declaration. This not only doesn't allow expression attributes to have attributes, but also produces spurious error diagnostics. In order to maintain all previously compiled code, we still assume that GNU attributes are followed by declarations unless ALL of those are statement attributes. And even in this case we are not forcing the parser to think that it should parse a statement, but rather let it proceed as if no attributes were found. Differential Revision: https://reviews.llvm.org/D93630
28 lines
653 B
C++
28 lines
653 B
C++
// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
|
|
|
|
#if !__has_extension(statement_attributes_with_gnu_syntax)
|
|
#error "We should have statement attributes with GNU syntax support"
|
|
#endif
|
|
|
|
template <typename T = void>
|
|
class __attribute__((nomerge)) A {
|
|
// expected-error@-1 {{'nomerge' attribute only applies to functions and statements}}
|
|
};
|
|
|
|
class B : public A<> {
|
|
public:
|
|
void bar();
|
|
};
|
|
|
|
void bar();
|
|
|
|
void foo(A<> *obj) {
|
|
__attribute__((nomerge)) static_cast<B *>(obj)->bar();
|
|
__attribute__((nomerge))[obj]() { static_cast<B *>(obj)->bar(); }
|
|
();
|
|
__attribute__(()) try {
|
|
bar();
|
|
} catch (...) {
|
|
}
|
|
}
|