Changeset View
Changeset View
Standalone View
Standalone View
clang/test/Preprocessor/ucn-pp-identifier.c
// RUN: %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -verify=expected,ext -Wundef | // RUN: %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -verify=expected,ext -Wundef -DTRIGRAPHS=1 | ||||
// RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify=expected,ext -Wundef | // RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify=expected,ext -Wundef -fno-trigraphs | ||||
// RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++2b -pedantic -ftrigraphs -verify=expected,cxx2b -Wundef -Wpre-c++2b-compat | // RUN: %clang_cc1 %s -fsyntax-only -x c++ -std=c++2b -pedantic -ftrigraphs -DTRIGRAPHS=1 -verify=expected,cxx2b -Wundef -Wpre-c++2b-compat | ||||
// RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify=expected,ext -Wundef -ftrigraphs -DTRIGRAPHS=1 | // RUN: %clang_cc1 %s -fsyntax-only -x c++ -pedantic -verify=expected,ext -Wundef -ftrigraphs -DTRIGRAPHS=1 | ||||
// RUN: not %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -Wundef 2>&1 | FileCheck -strict-whitespace %s | // RUN: not %clang_cc1 %s -fsyntax-only -std=c99 -pedantic -Wundef 2>&1 | FileCheck -strict-whitespace %s | ||||
#define \u00FC | #define \u00FC | ||||
#define a\u00FD() 0 | #define a\u00FD() 0 | ||||
#ifndef \u00FC | #ifndef \u00FC | ||||
#error "This should never happen" | #error "This should never happen" | ||||
#endif | #endif | ||||
Show All 23 Lines | |||||
#define \u0061 // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro name must be an identifier}} | #define \u0061 // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro name must be an identifier}} | ||||
#define \u{fffe} // expected-error {{macro name must be an identifier}} \ | #define \u{fffe} // expected-error {{macro name must be an identifier}} \ | ||||
// ext-warning {{extension}} cxx2b-warning {{before C++2b}} | // ext-warning {{extension}} cxx2b-warning {{before C++2b}} | ||||
#define \N{ALERT} // expected-error {{universal character name refers to a control character}} \ | #define \N{ALERT} // expected-error {{universal character name refers to a control character}} \ | ||||
// expected-error {{macro name must be an identifier}} \ | // expected-error {{macro name must be an identifier}} \ | ||||
// ext-warning {{extension}} cxx2b-warning {{before C++2b}} | // ext-warning {{extension}} cxx2b-warning {{before C++2b}} | ||||
#define \N{WASTEBASKET} // expected-error {{macro name must be an identifier}} \ | #define \N{WASTEBASKET} // expected-error {{macro name must be an identifier}} \ | ||||
// ext-warning {{extension}} cxx2b-warning {{before C++2b}} | // ext-warning {{extension}} cxx2b-warning {{before C++2b}} | ||||
#define a\u0024 | #define a\u0024 | ||||
#if \u0110 // expected-warning {{is not defined, evaluates to 0}} | #if \u0110 // expected-warning {{is not defined, evaluates to 0}} | ||||
#endif | #endif | ||||
#define \u0110 1 / 0 | #define \u0110 1 / 0 | ||||
#if \u0110 // expected-error {{division by zero in preprocessor expression}} | #if \u0110 // expected-error {{division by zero in preprocessor expression}} | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
// CHECK-NEXT: #define capital_u_\U00FC | // CHECK-NEXT: #define capital_u_\U00FC | ||||
// CHECK-NEXT: {{^ \^}} | // CHECK-NEXT: {{^ \^}} | ||||
// CHECK-NEXT: {{^ u}} | // CHECK-NEXT: {{^ u}} | ||||
#define \u{} // expected-warning {{empty delimited universal character name; treating as '\' 'u' '{' '}'}} expected-error {{macro name must be an identifier}} | #define \u{} // expected-warning {{empty delimited universal character name; treating as '\' 'u' '{' '}'}} expected-error {{macro name must be an identifier}} | ||||
#define \u{123456789} // expected-error {{hex escape sequence out of range}} expected-error {{macro name must be an identifier}} | #define \u{123456789} // expected-error {{hex escape sequence out of range}} expected-error {{macro name must be an identifier}} | ||||
#define \u{ // expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}} | #define \u{ // expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}} | ||||
#define \u{fgh} // expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}} | #define \u{fgh} // expected-warning {{incomplete delimited universal character name; treating as '\' 'u' '{' identifier}} expected-error {{macro name must be an identifier}} | ||||
#define \N{ // expected-warning {{incomplete delimited universal character name; treating as '\' 'N' '{' identifier}} expected-error {{macro name must be an identifier}} | #define \N{ | ||||
// expected-warning@-1 {{incomplete delimited universal character name; treating as '\' 'N' '{' identifier}} | |||||
// expected-error@-2 {{macro name must be an identifier}} | |||||
#define \N{} // expected-warning {{empty delimited universal character name; treating as '\' 'N' '{' '}'}} expected-error {{macro name must be an identifier}} | #define \N{} // expected-warning {{empty delimited universal character name; treating as '\' 'N' '{' '}'}} expected-error {{macro name must be an identifier}} | ||||
#define \N{NOTATHING} // expected-error {{'NOTATHING' is not a valid Unicode character name}} \ | #define \N{NOTATHING} // expected-error {{'NOTATHING' is not a valid Unicode character name}} \ | ||||
// expected-error {{macro name must be an identifier}} | // expected-error {{macro name must be an identifier}} | ||||
#define \NN // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{macro name must be an identifier}} | #define \NN // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{macro name must be an identifier}} | ||||
#define \N{GREEK_SMALL-LETTERALPHA} // expected-error {{'GREEK_SMALL-LETTERALPHA' is not a valid Unicode character name}} \ | #define \N{GREEK_SMALL-LETTERALPHA} // expected-error {{'GREEK_SMALL-LETTERALPHA' is not a valid Unicode character name}} \ | ||||
// expected-note {{characters names in Unicode escape sequences are sensitive to case and whitespaces}} | // expected-note {{characters names in Unicode escape sequences are sensitive to case and whitespaces}} | ||||
#define \N{🤡} // expected-error {{'🤡' is not a valid Unicode character name}} \ | |||||
// expected-error {{macro name must be an identifier}} | |||||
#define CONCAT(A, B) A##B | #define CONCAT(A, B) A##B | ||||
int CONCAT(\N{GREEK, CAPITALLETTERALPHA}); // expected-error{{expected}} \ | int CONCAT(\N{GREEK | ||||
// expected-warning {{incomplete delimited universal character name}} | , CAPITALLETTERALPHA}); | ||||
aaron.ballman: Why did this test get removed? | |||||
It doesn't test anything anymore, as the comma is part of the escape sequence now cor3ntin: It doesn't test anything anymore, as the comma is part of the escape sequence now
Thinking… | |||||
// expected-error@-2 {{expected}} \ | |||||
// expected-warning@-2 {{incomplete delimited universal character name}} | |||||
int \N{\ | |||||
LATIN CAPITAL LETTER A WITH GRAVE}; | |||||
//ext-warning@-2 {{extension}} cxx2b-warning@-2 {{before C++2b}} | |||||
Not Done ReplyInline ActionsHow about adding a test for an escaped new line? I think this is currently UB according to the standard ((lex.phases)p2), but I believe you are trying to change that with P2621. int \N{\ LATIN CAPITAL LETTER A WITH GRAVE}; tahonermann: How about adding a test for an escaped new line? I think this is currently UB according to the… | |||||
I can add a test, sure cor3ntin: I can add a test, sure
P2621 is not super relevant (or rather, it standardize behaviors that… | |||||
#ifdef TRIGRAPHS | #ifdef TRIGRAPHS | ||||
int \N??<GREEK CAPITAL LETTER ALPHA??> = 0; // expected-warning{{extension}} cxx2b-warning {{before C++2b}} \ | int \N??<GREEK CAPITAL LETTER ALPHA??> = 0; // cxx2b-warning {{before C++2b}} \ | ||||
//ext-warning {{extension}}\ | |||||
// expected-warning 2{{trigraph converted}} | // expected-warning 2{{trigraph converted}} | ||||
int a\N{LATIN CAPITAL LETTER A WITH GRAVE??>; // expected-warning {{trigraph converted}} | |||||
#endif | |||||
#ifndef TRIGRAPHS | |||||
int a\N{LATIN CAPITAL LETTER A WITH GRAVE??>; | |||||
// expected-warning@-1 {{trigraph ignored}}\ | |||||
// expected-warning@-1 {{incomplete}}\ | |||||
// expected-error@-1 {{expected ';' after top level declarator}} | |||||
#endif | #endif |
Why did this test get removed?