Skip to content

Instantly share code, notes, and snippets.

@vsapsai
Created January 11, 2018 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsapsai/d61a8a7d06356a18db26658acc0c4b25 to your computer and use it in GitHub Desktop.
Save vsapsai/d61a8a7d06356a18db26658acc0c4b25 to your computer and use it in GitHub Desktop.
clang/test/Lexer/null-character-in-literal.c for https://reviews.llvm.org/D41423
// RUN: %clang_cc1 -fsyntax-only -verify %s
// This file contains literal null characters, be careful not to remove them
// accidentally.
char a = ''; // expected-warning {{null character(s) preserved in char literal}}
char b = '\'; // expected-warning {{null character(s) preserved in char literal}}
// expected-warning@-1 {{unknown escape sequence '\x0'}}
char *c = "nullcharacter"; // expected-warning {{null character(s) preserved in string literal}}
char *d = "null\character"; // expected-warning {{null character(s) preserved in string literal}}
// expected-warning@-1 {{unknown escape sequence '\x0'}}
// Put broken include in the end because it suppresses subsequent warnings.
#include <null\character> // expected-warning {{null character(s) preserved in string literal}}
// expected-error@-1 {{'null\character' file not found}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment