================
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -std=c++26 -fexperimental-new-constant-interpreter -x c++ 
%s -verify
+
+struct F {
+  bool V;
+};
+// Nominal cases
+// Type
+constexpr F f{true};
+struct [[=1]] f1 {};
+struct [[=1, =F{true}, =f]] f2 {};
+struct [[=1]] [[=2]] f3 {};
+// Declaration
+[[=1]] const F f4{}; // before declarator
+const F [[=1]] f40{}; // after declarator
+void f41([[=F{false}]]int i) {} // function parameters
+template<class T> [[=3]] void f42(T t); // non dep on template decl
+// Redeclaration
+[[=2, =3, =2]] void f5();
+void f5 [[=4, =2]] ();
+// Alias
+using A1 [[=1]] = int;
+// Error case
+// Right hand side of a alias declaration
+using A2 = [[=2]] int;  // expected-error {{an attribute list cannot appear 
here}}
+using A3 = int [[=2]];  // expected-error {{annotations are not permitted on 
defining-type-id}}
+// Mixing annotation and attributes, with or without trailing characters
+struct [[nodiscard, =1]] f6 {};  // expected-error {{attribute specifier 
cannot contain both attributes and annotations}}
+struct [[nodiscard, =1,]] f7 {};  // expected-error {{attribute specifier 
cannot contain both attributes and annotations}}
+struct [[=1, nodiscard, ]] f8 {};  // expected-error {{attribute specifier 
cannot contain both attributes and annotations}}
+struct [[=1, nodiscard ]] f9 {};  // expected-error {{attribute specifier 
cannot contain both attributes and annotations}}
+// Mixing attribute using and annotation
+struct G {
+  [[using CC: =1]] [[=2]] int f;  // expected-error {{annotations are not 
permitted following an attribute-using-prefix}}
+};
+// Substituting into an annotation is not in the immediate context
+template<class T>
+  [[=T::type()]] void h(T t); // expected-error {{type 'char' cannot be used 
prior to '::' because it has no members}}
+                              // expected-note@#inst-H {{in instantiation of 
function template specialization 'h<char>' requested here}}
+struct T {
+  static constexpr int type() { return 0; }
+};
+
+void h(int);
+void hh() {
+  h(0);
----------------
shafik wrote:

So why does `int::type()` work? I am looking at the proposal where this example 
comes from and I feel like I am missing something here. I see the `void h(int)` 
above but that still does not help me.

https://github.com/llvm/llvm-project/pull/166287
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to