brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 8f321d8 Raw
28 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++112 3template<typename T>4struct only {5  only(T);6  template<typename U> only(U) = delete;7};8 9void f() {10  only<const int*> p = new const auto (0);11  only<double*> q = new (auto) (0.0);12  only<char*> r = new auto {'a'};13 14  new auto; // expected-error{{new expression for type 'auto' requires a constructor argument}}15  new (const auto)(); // expected-error{{new expression for type 'const auto' requires a constructor argument}}16  new (auto) (1,2,3); // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}17  new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}18  new auto {1,2,3}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}19  new auto ({1,2,3}); // expected-error{{cannot deduce actual type for 'auto' from parenthesized initializer list}}20}21 22void p2example() {23  only<int*> r = new auto(1);24  auto x = new auto('a');25 26  only<char*> testX = x;27}28