| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| // RUN: %clang_cc1 -verify -std=c99 %s | ||
| // RUN: %clang_cc1 -verify -std=c99 -fno-dollars-in-identifiers %s | ||
|
|
||
| /* WG14 N717: Clang 17 | ||
| * Extended identifiers | ||
| */ | ||
|
|
||
| // Used as a sink for UCNs. | ||
| #define M(arg) | ||
|
|
||
| // C99 6.4.3p1 specifies the grammar for UCNs. A \u must be followed by exactly | ||
| // four hex digits, and \U must be followed by exactly eight. | ||
| M(\u1) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\u12) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\u123) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\u1234) // Okay | ||
| M(\u12345)// Okay, two tokens (UCN followed by 5) | ||
|
|
||
| M(\U1) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\U12) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\U123) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\U1234) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} \ | ||
| expected-note {{did you mean to use '\u'?}} | ||
| M(\U12345) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\U123456) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\U1234567) // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} | ||
| M(\U12345678) // Okay | ||
| M(\U123456789) // Okay-ish, two tokens (valid-per-spec-but-actually-invalid UCN followed by 9) | ||
|
|
||
| // Now test the ones that should work. Note, these work in C17 and earlier but | ||
| // are part of the basic character set in C23 and thus should be diagnosed in | ||
| // that mode. They're valid in a character constant, but not valid in an | ||
| // identifier, except for U+0024 which is allowed if -fdollars-in-identifiers | ||
| // is enabled. | ||
| // FIXME: These three should be handled the same way, and should be accepted | ||
| // when dollar signs are allowed in identifiers, rather than rejected, see | ||
| // GH87106. | ||
| M(\u0024) // expected-error {{character '$' cannot be specified by a universal character name}} | ||
| M(\U00000024) // expected-error {{character '$' cannot be specified by a universal character name}} | ||
| M($) | ||
|
|
||
| // These should always be rejected because they're not valid identifier | ||
| // characters. | ||
| // FIXME: the diagnostic could be improved to make it clear this is an issue | ||
| // with forming an identifier rather than a UCN. | ||
| M(\u0040) // expected-error {{character '@' cannot be specified by a universal character name}} | ||
| M(\u0060) // expected-error {{character '`' cannot be specified by a universal character name}} | ||
| M(\U00000040) // expected-error {{character '@' cannot be specified by a universal character name}} | ||
| M(\U00000060) // expected-error {{character '`' cannot be specified by a universal character name}} | ||
|
|
||
| // UCNs outside of identifiers are handled in Phase 5 of translation, so we | ||
| // cannot use the macro expansion to test their behavior. | ||
|
|
||
| // This is outside of the range of values specified by ISO 10646. | ||
| const char *c1 = "\U00110000"; // expected-error {{invalid universal character}} | ||
| // This does not fall outside of the range | ||
| const char *c2 = "\U0010FFFF"; | ||
|
|
||
| // These should always be accepted because they're a valid in a character | ||
| // constant. | ||
| int c3 = '\u0024'; | ||
| int c4 = '\u0040'; | ||
| int c5 = '\u0060'; | ||
|
|
||
| int c6 = '\U00000024'; | ||
| int c7 = '\U00000040'; | ||
| int c8 = '\U00000060'; | ||
|
|
||
| // Valid lone surrogates. | ||
| M(\uD799) | ||
| const char *c9 = "\U0000E000"; | ||
|
|
||
| // Invalid lone surrogates, which are excluded explicitly by 6.4.3p2. | ||
| M(\uD800) // expected-error {{invalid universal character}} | ||
| const char *c10 = "\U0000DFFF"; // expected-error {{invalid universal character}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-library -fnative-half-type -Wconversion -verify %s | ||
|
|
||
| void literal_assignments() { | ||
| half h; | ||
|
|
||
| h = 2.0h; // No conversion, no diagnostic expected. | ||
|
|
||
| // Literal conversions that don't lose precision also don't cause diagnostics. | ||
| // Conversion from double (no diagnostic expected) | ||
| h = 2.0l; | ||
| h = 2.0; | ||
| h = 2.0f; | ||
|
|
||
| // Literal assignments with conversions that lose precision produce | ||
| // diagnostics under `-Wconversion`. | ||
|
|
||
| // Lose precision on assignment. | ||
| h = 3.1415926535897932384626433h; // No diagnostic expected because this isn't a conversion. | ||
|
|
||
| // Lose precision on assignment converting float to half. | ||
| h = 3.1415926535897932384626433f; // expected-warning {{implicit conversion loses floating-point precision: 'float' to 'half'}} | ||
|
|
||
| // Lose precision on assignment converting float to half. | ||
| h = 3.1415926535897932384626433f * 2.0f; // expected-warning {{implicit conversion loses floating-point precision: 'float' to 'half'}} | ||
|
|
||
| // Lose precision on assignment converting double to half. | ||
| h = 3.1415926535897932384626433l; // expected-warning {{implicit conversion loses floating-point precision: 'double' to 'half'}} | ||
|
|
||
| // Lose precision on assignment converting double to half. | ||
| h = 3.1415926535897932384626433l * 2.0l; // expected-warning {{implicit conversion loses floating-point precision: 'double' to 'half'}} | ||
|
|
||
| // Literal assinments of values out of the representable range produce | ||
| // warnings. | ||
|
|
||
| h = 66000.h; // expected-warning {{magnitude of floating-point constant too large for type 'half'; maximum is 65504}} | ||
| h = -66000.h; // expected-warning {{magnitude of floating-point constant too large for type 'half'; maximum is 65504}} | ||
|
|
||
| // The `h` suffix is invalid on integer literals. | ||
| h = 66000h; // expected-error {{invalid suffix 'h' on integer constant}} | ||
| } | ||
|
|
||
| template <typename T, typename U> | ||
| struct is_same { | ||
| static const bool value = false; | ||
| }; | ||
|
|
||
| template <typename T> | ||
| struct is_same<T, T> { | ||
| static const bool value = true; | ||
| }; | ||
|
|
||
| // The no-suffix behavior is currently wrong. The behavior in DXC is complicated | ||
| // and undocumented. We have a language change planned to address this, and an | ||
| // issue tracking: https://github.com/llvm/llvm-project/issues/85714. | ||
| _Static_assert(is_same<double, __decltype(1.0)>::value, "1.0f literal is double (should be float)"); | ||
|
|
||
| _Static_assert(is_same<half, __decltype(1.0h)>::value, "1.0h literal is half"); | ||
| _Static_assert(is_same<float, __decltype(1.0f)>::value, "1.0f literal is float"); | ||
| _Static_assert(is_same<double, __decltype(1.0l)>::value, "1.0l literal is double"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-library -Wconversion -verify %s | ||
|
|
||
| void literal_assignments() { | ||
| half h; | ||
|
|
||
| h = 2.0h; // No conversion, no diagnostic expected. | ||
|
|
||
| // Literal conversions that don't lose precision also don't cause diagnostics. | ||
| // Conversion from double (no diagnostic expected) | ||
| h = 2.0l; | ||
| h = 2.0; | ||
| h = 2.0f; | ||
|
|
||
| // Literal assignments with conversions that lose precision produce | ||
| // diagnostics under `-Wconversion`. | ||
|
|
||
| // Lose precision on assignment. | ||
| h = 3.1415926535897932384626433h; // No diagnostic expected because this isn't a conversion. | ||
|
|
||
| // Lose precision on assignment converting float to half. | ||
| h = 3.1415926535897932384626433f; // No diagnostic expected because half and float are the same size. | ||
|
|
||
| // Lose precision on assignment converting float to half. | ||
| h = 3.1415926535897932384626433f * 2.0f; // No diagnostic expected because half and float are the same size. | ||
|
|
||
| // Lose precision on assignment converting double to half. | ||
| h = 3.1415926535897932384626433l; // expected-warning {{implicit conversion loses floating-point precision: 'double' to 'half'}} | ||
|
|
||
| // Lose precision on assignment converting double to half. | ||
| h = 3.1415926535897932384626433l * 2.0l; // expected-warning {{implicit conversion loses floating-point precision: 'double' to 'half'}} | ||
|
|
||
| // Literal assinments of values out of the representable range produce | ||
| // warnings. | ||
|
|
||
| h = 66000.h; // No diagnostic expected because half is 32-bit. | ||
| h = -66000.h; // No diagnostic expected because half is 32-bit. | ||
|
|
||
| // The `h` suffix is invalid on integer literals. | ||
| h = 66000h; // expected-error {{invalid suffix 'h' on integer constant}} | ||
| } | ||
|
|
||
| template <typename T, typename U> | ||
| struct is_same { | ||
| static const bool value = false; | ||
| }; | ||
|
|
||
| template <typename T> | ||
| struct is_same<T, T> { | ||
| static const bool value = true; | ||
| }; | ||
|
|
||
| // The no-suffix behavior is currently wrong. The behavior in DXC is complicated | ||
| // and undocumented. We have a language change planned to address this, and an | ||
| // issue tracking: https://github.com/llvm/llvm-project/issues/85714. | ||
| _Static_assert(is_same<double, __decltype(1.0)>::value, "1.0f literal is double (should be float)"); | ||
|
|
||
| _Static_assert(is_same<half, __decltype(1.0h)>::value, "1.0h literal is half"); | ||
| _Static_assert(is_same<float, __decltype(1.0f)>::value, "1.0f literal is float"); | ||
| _Static_assert(is_same<double, __decltype(1.0l)>::value, "1.0l literal is double"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <!--===- docs/Real16MathSupport.md | ||
| Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| See https://llvm.org/LICENSE.txt for license information. | ||
| SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| --> | ||
|
|
||
| # Flang support for REAL(16) math intrinsics | ||
|
|
||
| To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies | ||
| on third-party libraries providing the implementation. | ||
|
|
||
| `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used | ||
| to build `FortranFloat128Math` library that has unresolved references | ||
| to GCC `libquadmath` library. A Flang driver built with this option | ||
| will automatically link `FortranFloat128Math` and `libquadmath` libraries | ||
| to any Fortran program. This implies that `libquadmath` library | ||
| has to be available in the standard library paths, so that linker | ||
| can find it. The `libquadmath` library installation into Flang project | ||
| distribution is not automatic in CMake currently. | ||
|
|
||
| Testing shows that `libquadmath` versions before GCC-9.3.0 have | ||
| accuracy issues, so it is recommended to distribute the Flang | ||
| package with later versions of `libquadmath`. | ||
|
|
||
| Care must be taken by the distributors of a Flang package built | ||
| with `REAL(16)` support via `libquadmath` because of its licensing | ||
| under the GNU Library General Public License. Moreover, static linking | ||
| of `libquadmath` to the Flang users' programs may imply some | ||
| restrictions/requirements. This document is not intended to give | ||
| any legal advice on distributing such a Flang compiler. | ||
|
|
||
| Flang compiler targeting systems with `LDBL_MANT_DIG == 113` | ||
| may provide `REAL(16)` math support without a `libquadmath` | ||
| dependency, using standard `libc` APIs for the `long double` | ||
| data type. It is not recommended to use the above CMake option | ||
| for building Flang compilers for such targets. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| #define LLVM_LIBC_SRC_STDIO_FSEEKO_H | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| #define LLVM_LIBC_SRC_STDIO_FTELLO_H | ||
|
|
||
| #include <stdio.h> | ||
|
|
||
| namespace LIBC_NAMESPACE { | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| ## Test certain REL relocation types generated by legacy armasm. | ||
| # RUN: yaml2obj %s -o %t.o | ||
| # RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s | ||
|
|
||
| # CHECK-COUNT-17: internal linker error: cannot read addend | ||
|
|
||
| --- | ||
| !ELF | ||
| FileHeader: | ||
| Class: ELFCLASS64 | ||
| Data: ELFDATA2LSB | ||
| Type: ET_REL | ||
| Machine: EM_AARCH64 | ||
| Sections: | ||
| - Name: .abs | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_ALLOC ] | ||
| Content: fffffefffffffdfffffffffffffffcffffffffffffff | ||
| - Name: .rel.abs | ||
| Type: SHT_REL | ||
| Link: .symtab | ||
| Info: .abs | ||
| Relocations: | ||
| - {Offset: 0, Symbol: abs, Type: R_AARCH64_ABS16} | ||
| - {Offset: 2, Symbol: abs, Type: R_AARCH64_ABS32} | ||
| - {Offset: 6, Symbol: abs, Type: R_AARCH64_ABS64} | ||
| - {Offset: 14, Symbol: abs, Type: R_AARCH64_ADD_ABS_LO12_NC} | ||
|
|
||
| - Name: .uabs | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_ALLOC ] | ||
| AddressAlign: 4 | ||
| Content: 00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff | ||
| - Name: .rel.uabs | ||
| Type: SHT_REL | ||
| Link: .symtab | ||
| Info: .uabs | ||
| Relocations: | ||
| - {Offset: 0, Symbol: abs, Type: R_AARCH64_MOVW_UABS_G0} | ||
| - {Offset: 4, Symbol: abs, Type: R_AARCH64_MOVW_UABS_G0_NC} | ||
| - {Offset: 8, Symbol: abs, Type: R_AARCH64_MOVW_UABS_G1} | ||
| - {Offset: 12, Symbol: abs, Type: R_AARCH64_MOVW_UABS_G1_NC} | ||
| - {Offset: 16, Symbol: abs, Type: R_AARCH64_MOVW_UABS_G2} | ||
| - {Offset: 20, Symbol: abs, Type: R_AARCH64_MOVW_UABS_G2_NC} | ||
|
|
||
| - Name: .prel | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_ALLOC ] | ||
| AddressAlign: 4 | ||
| Content: 00ffffff00ffffff00ffffff00ffffff00ffffff00ffffff | ||
| - Name: .rel.prel | ||
| Type: SHT_REL | ||
| Link: .symtab | ||
| Info: .prel | ||
| Relocations: | ||
| - {Offset: 0, Symbol: .prel, Type: R_AARCH64_PREL64} | ||
| - {Offset: 4, Symbol: .prel, Type: R_AARCH64_PREL32} | ||
| - {Offset: 8, Symbol: .prel, Type: R_AARCH64_PREL16} | ||
| - {Offset: 12, Symbol: .prel, Type: R_AARCH64_LD_PREL_LO19} | ||
| - {Offset: 16, Symbol: .prel, Type: R_AARCH64_ADR_PREL_PG_HI21} | ||
| - {Offset: 20, Symbol: .prel, Type: R_AARCH64_ADR_PREL_PG_HI21_NC} | ||
|
|
||
| - Name: .branch | ||
| Type: SHT_PROGBITS | ||
| Flags: [ SHF_ALLOC ] | ||
| AddressAlign: 4 | ||
| Content: f0fffffff0fffffff0fffffff0ffffff | ||
| - Name: .rel.branch | ||
| Type: SHT_REL | ||
| Link: .symtab | ||
| Info: .branch | ||
| Relocations: | ||
| - {Offset: 0, Symbol: .branch, Type: R_AARCH64_TSTBR14} | ||
| - {Offset: 4, Symbol: .branch, Type: R_AARCH64_CONDBR19} | ||
| - {Offset: 8, Symbol: .branch, Type: R_AARCH64_CALL26} | ||
| - {Offset: 12, Symbol: .branch, Type: R_AARCH64_JUMP26} | ||
|
|
||
| Symbols: | ||
| - Name: .branch | ||
| Section: .branch | ||
| - Name: .prel | ||
| Section: .prel | ||
| - Name: abs | ||
| Index: SHN_ABS | ||
| Value: 42 | ||
| Binding: STB_GLOBAL |