view clang/test/Parser/stmt-attributes.cpp @ 223:5f17cb93ff66 llvm-original

LLVM13 (2021/7/18)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:43:00 +0900
parents 79ff65ed7e25
children 1f2b6ac9f198
line wrap: on
line source

// 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 (...) {
  }
}