79 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s2//3// This test checks that a deprecated attribute on an alias4// template triggers a warning diagnostic when it is used.5 6template <typename T>7struct NoAttr {8 void foo() {}9};10 11// expected-note@+2 7{{'UsingWithAttr' has been explicitly marked deprecated here}}12template <typename T>13using UsingWithAttr __attribute__((deprecated)) = NoAttr<T>;14 15// expected-note@+1 {{'UsingInstWithAttr' has been explicitly marked deprecated here}}16using UsingInstWithAttr __attribute__((deprecated)) = NoAttr<int>;17 18// expected-note@+1 {{'TDWithAttr' has been explicitly marked deprecated here}}19typedef NoAttr<int> TDWithAttr __attribute__((deprecated));20 21// expected-warning@+1 {{'UsingWithAttr' is deprecated}}22typedef UsingWithAttr<int> TDUsingWithAttr;23 24typedef NoAttr<int> TDNoAttr;25 26// expected-note@+1 {{'UsingTDWithAttr' has been explicitly marked deprecated here}}27using UsingTDWithAttr __attribute__((deprecated)) = TDNoAttr;28 29struct S {30 NoAttr<float> f1;31 // expected-warning@+1 {{'UsingWithAttr' is deprecated}}32 UsingWithAttr<float> f2;33};34 35// expected-warning@+1 {{'UsingWithAttr' is deprecated}}36void foo(NoAttr<short> s1, UsingWithAttr<short> s2) {37}38 39// expected-note@+2 {{'UsingWithCPPAttr' has been explicitly marked deprecated here}}40template <typename T>41using UsingWithCPPAttr [[deprecated]] = NoAttr<T>;42 43// expected-note@+1 {{'UsingInstWithCPPAttr' has been explicitly marked deprecated here}}44using UsingInstWithCPPAttr [[deprecated("Do not use this")]] = NoAttr<int>;45 46void bar() {47 NoAttr<int> obj; // Okay48 49 // expected-warning@+1 {{'UsingWithAttr' is deprecated}}50 UsingWithAttr<int> objUsingWA;51 52 // expected-warning@+1 {{'UsingWithAttr' is deprecated}}53 NoAttr<UsingWithAttr<int>> s;54 55 // expected-note@+1 {{'DepInt' has been explicitly marked deprecated here}}56 using DepInt [[deprecated]] = int;57 // expected-warning@+2 {{'UsingWithAttr' is deprecated}}58 // expected-warning@+1 {{'DepInt' is deprecated}}59 using X = UsingWithAttr<DepInt>;60 61 // expected-warning@+1 {{'UsingWithAttr' is deprecated}}62 UsingWithAttr<int>().foo();63 64 // expected-warning@+1 {{'UsingInstWithAttr' is deprecated}}65 UsingInstWithAttr objUIWA;66 67 // expected-warning@+1 {{'TDWithAttr' is deprecated}}68 TDWithAttr objTDWA;69 70 // expected-warning@+1 {{'UsingTDWithAttr' is deprecated}}71 UsingTDWithAttr objUTDWA;72 73 // expected-warning@+1 {{'UsingWithCPPAttr' is deprecated}}74 UsingWithCPPAttr<int> objUsingWCPPA;75 76 // expected-warning@+1 {{'UsingInstWithCPPAttr' is deprecated: Do not use this}}77 UsingInstWithCPPAttr objUICPPWA;78}79