mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 14:16:08 +00:00

The attributes changes were left out of Clang 17. Attributes that used to take a string literal now accept an unevaluated string literal instead, which means they reject numeric escape sequences and strings literal with an encoding prefix - but the later was already ill-formed in most cases. We need to know that we are going to parse an unevaluated string literal before we do - so we can reject numeric escape sequence, so we derive from Attrs.td which attributes parameters are expected to be string literals. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D156237
15 lines
942 B
C
15 lines
942 B
C
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -fsyntax-only %s
|
|
|
|
#if !__has_attribute(tls_model)
|
|
#error "Should support tls_model attribute"
|
|
#endif
|
|
|
|
int f(void) __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
|
|
|
|
int x __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}}
|
|
static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
|
|
|
|
static __thread int y __attribute((tls_model("local", "dynamic"))); // expected-error {{'tls_model' attribute takes one argument}}
|
|
static __thread int y __attribute((tls_model(123))); // expected-error {{expected string literal as argument of 'tls_model' attribute}}
|
|
static __thread int y __attribute((tls_model("foobar"))); // expected-error {{tls_model must be "global-dynamic", "local-dynamic", "initial-exec" or "local-exec"}}
|