brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.5 KiB · 38c2e57 Raw
119 lines · c
1#if GC2# define GCONST const3#else4# define GCONST5#endif6 7// gconst-note@8 {{variable 'glb' declared const here}}8GCONST int glb = 5;9 10 11// Check various correct prefix spellings and combinations.12//13// RUN: %clang_cc1             -DGC           -verify=gconst                 %s14// RUN: %clang_cc1 -Wcast-qual      -DLC      -verify=lconst                 %s15// RUN: %clang_cc1                       -DSC -verify=expected               %s16// RUN: %clang_cc1                       -DSC -verify                        %s17// RUN: %clang_cc1                       -DSC -verify -verify                %s18// RUN: %clang_cc1                            -verify=nconst                 %s19// RUN: %clang_cc1                            -verify=n-const                %s20// RUN: %clang_cc1                            -verify=n_const                %s21// RUN: %clang_cc1                            -verify=NConst                 %s22// RUN: %clang_cc1                            -verify=NConst2                %s23// RUN: %clang_cc1 -Wcast-qual -DGC -DLC      -verify=gconst,lconst          %s24// RUN: %clang_cc1 -Wcast-qual -DGC -DLC -DSC -verify=gconst,lconst,expected %s25// RUN: %clang_cc1 -Wcast-qual -DGC -DLC      -verify=gconst -verify=lconst  %s26// RUN: %clang_cc1 -Wcast-qual -DGC -DLC -DSC -verify=gconst,lconst -verify  %s27// RUN: %clang_cc1             -DGC      -DSC -verify -verify=gconst -verify %s28//29// Duplicate prefixes.30// RUN: %clang_cc1 -Wcast-qual -DGC -DLC      -verify=gconst,lconst,gconst         %s31// RUN: %clang_cc1             -DGC           -verify=gconst -verify=gconst,gconst %s32// RUN: %clang_cc1                       -DSC -verify=expected -verify=expected    %s33// RUN: %clang_cc1                       -DSC -verify -verify=expected             %s34//35// Various tortured cases: multiple directives with different prefixes per36// line, prefixes used as comments, prefixes prefixing prefixes, and prefixes37// with special suffixes.38// RUN: %clang_cc1 -Wcast-qual      -DLC      -verify=foo                    %s39// RUN: %clang_cc1                       -DSC -verify=bar                    %s40// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=foo,bar                %s41// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=bar,foo                %s42// RUN: %clang_cc1                       -DSC -verify=foo-bar                %s43// RUN: %clang_cc1 -Wcast-qual      -DLC      -verify=bar-foo                %s44// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=foo,foo-bar            %s45// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=foo-bar,foo            %s46// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=bar,bar-foo            %s47// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=bar-foo,bar            %s48// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=foo-bar,bar-foo        %s49// RUN: %clang_cc1                       -DSC -verify=foo-warning            %s50// RUN: %clang_cc1 -Wcast-qual      -DLC      -verify=bar-warning-re         %s51// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=foo,foo-warning        %s52// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=foo-warning,foo        %s53// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=bar,bar-warning-re     %s54// RUN: %clang_cc1 -Wcast-qual      -DLC -DSC -verify=bar-warning-re,bar     %s55 56 57// Check invalid prefixes.  Check that there's no additional output, which58// might indicate that diagnostic verification became enabled even though it59// was requested incorrectly.  Check that prefixes are reported in command-line60// order.61//62// RUN: not %clang_cc1 -verify=5abc,-xy,foo,_k -verify='#a,b$' %s 2> %t63// RUN: FileCheck --check-prefixes=ERR %s < %t64//65// ERR-NOT:  {{.}}66// ERR:      error: invalid value '5abc' in '-verify='67// ERR-NEXT: note: -verify prefixes must start with a letter and contain only alphanumeric characters, hyphens, and underscores68// ERR-NEXT: error: invalid value '-xy' in '-verify='69// ERR-NEXT: note: -verify prefixes must start with a letter and contain only alphanumeric characters, hyphens, and underscores70// ERR-NEXT: error: invalid value '_k' in '-verify='71// ERR-NEXT: note: -verify prefixes must start with a letter and contain only alphanumeric characters, hyphens, and underscores72// ERR-NEXT: error: invalid value '#a' in '-verify='73// ERR-NEXT: note: -verify prefixes must start with a letter and contain only alphanumeric characters, hyphens, and underscores74// ERR-NEXT: error: invalid value 'b$' in '-verify='75// ERR-NEXT: note: -verify prefixes must start with a letter and contain only alphanumeric characters, hyphens, and underscores76// ERR-NOT:  {{.}}77 78 79// Check that our test code actually has expected diagnostics when there's no80// -verify.81//82// RUN: not %clang_cc1 -Wcast-qual -DGC -DLC -DSC %s 2> %t83// RUN: FileCheck --check-prefix=ALL %s < %t84//85// ALL: cannot assign to variable 'glb' with const-qualified type 'const int'86// ALL: variable 'glb' declared const here87// ALL: cast from 'const int *' to 'int *' drops const qualifier88// ALL: initializing 'int *' with an expression of type 'const int *' discards qualifiers89 90 91#if LC92# define LCONST const93#else94# define LCONST95#endif96 97#if SC98# define SCONST const99#else100# define SCONST101#endif102 103void foo(void) {104  LCONST int loc = 5;105  SCONST static int sta = 5;106  // We don't actually expect 1-2 occurrences of this error.  We're just107  // checking the parsing.108  glb = 6; // gconst-error1-2 {{cannot assign to variable 'glb' with const-qualified type 'const int'}}109  *(int*)(&loc) = 6; // lconst-warning {{cast from 'const int *' to 'int *' drops const qualifier}}110  ; // Code, comments, and many directives with different prefixes per line, including cases where some prefixes (foo and bar) prefix others (such as foo-bar and bar-foo), such that some prefixes appear as normal comments and some have special suffixes (-warning and -re): foo-warning@-1 {{cast from 'const int *' to 'int *' drops const qualifier}} foo-bar-warning@+1 {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}} foo-warning-warning@+1 {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}} bar-warning-re-warning@-1 {{cast from 'const int *' to 'int *' drops const qualifier}} bar-foo-warning@-1 {{cast from 'const int *' to 'int *' drops const qualifier}} bar-warning@+1 {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}111  int *p = &sta; // expected-warning {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}112}113 114// nconst-no-diagnostics115// n-const-no-diagnostics116// n_const-no-diagnostics117// NConst-no-diagnostics118// NConst2-no-diagnostics119