
This causes us to generate an enum to go along with the select diagnostic, which allows for clearer diagnostic error emit lines. The syntax for this is: %enum_select<EnumerationName>{%OptionalEnumeratorName{Text}|{Text2}}0 Where the curley brackets around the select-text are only required if an Enumerator name is provided. The TableGen here emits this as a normal 'select' to the frontend, which permits us to reuse all of the existing 'select' infrastructure. Documentation is the same as well. --------- Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
46 lines
1.8 KiB
TableGen
46 lines
1.8 KiB
TableGen
// RUN: not clang-tblgen --gen-clang-diags-enums -DERROR1 -I%S %s 2>&1 | FileCheck %s --check-prefixes=CHECK,C1
|
|
// RUN: not clang-tblgen --gen-clang-diags-enums -DERROR2 -I%S %s 2>&1 | FileCheck %s --check-prefixes=CHECK,C2
|
|
// RUN: not clang-tblgen --gen-clang-diags-enums -DERROR3 -I%S %s 2>&1 | FileCheck %s --check-prefixes=CHECK,C3
|
|
// RUN: not clang-tblgen --gen-clang-diags-enums -DERROR4 -I%S %s 2>&1 | FileCheck %s --check-prefixes=CHECK,C4
|
|
include "DiagnosticBase.inc"
|
|
|
|
// No real reason to diagnose these, the namespace generated as the
|
|
// 'enumeration' name will never conflict with the enumerator.
|
|
def EnumerationEnumeratorDupe : Error<"%enum_select<Matchy>{%Matchy{haha}}0">;
|
|
|
|
// Enumerator values aren't required, though this does seem kind of silly/not
|
|
// particularly useful?
|
|
def NoEnumerators : Error<"%enum_select<Name>{foo|bar|baz}0">;
|
|
|
|
def DupeNames1 : Error<"%enum_select<DupeName>{}0">;
|
|
def DupeNames2 : Error<"%enum_select<DupeName>{}0">;
|
|
// CHECK: error: Duplicate enumeration name 'DupeName'
|
|
// CHECK-NEXT: def DupeNames2
|
|
// CHECK: note: Previous diagnostic is here
|
|
// CHECK-NEXT: def DupeNames1
|
|
|
|
def DupeValue : Error<"%enum_select<DupeValue>{%DName{V1}|%DName{V2}}0">;
|
|
// CHECK: error: Duplicate enumerator name 'DName'
|
|
|
|
#ifdef ERROR1
|
|
def EnumValNotExpected : Error<"%enum_select{V1|%Val2{V2}}0">;
|
|
// C1: expected '<' after enum_select
|
|
#endif
|
|
|
|
#ifdef ERROR2
|
|
def SelectWithArrow : Error<"%select<Something>{V1|%Val2{V2}}0">;
|
|
// C2: modifier '<' syntax not valid with %select
|
|
#endif
|
|
|
|
#ifdef ERROR3
|
|
// Missing closing > after the name of the enumeration
|
|
def MissingClosing : Error<"%enum_select<MissingClosingName{}0">;
|
|
// C3: expected '>' while parsing %enum_select
|
|
#endif
|
|
|
|
#ifdef ERROR4
|
|
// Missing { after the name of an enumerator
|
|
def MissingTextAfterEnumerator: Error<"%enum_select<Name>{%OtherName|foo}0">;
|
|
// C4: expected '{' while parsing %enum_select
|
|
#endif
|