brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · e20c9f7 Raw
45 lines · c
1// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic %s2 3/* WG14 N3348: No4 * Matching of Multi-Dimensional Arrays in Generic Selection Expressions5 *6 * This allows use of * in a _Generic association as a placeholder for any size7 * value.8 *9 * FIXME: Clang doesn't yet implement this paper. When we do implement it, we10 * should expose the functionality in earlier language modes (C89) for11 * compatibility with GCC.12 */13 14void test(int n, int m) {15  static_assert(1 == _Generic(int[3][2], int[3][*]: 1, int[2][*]: 0));  /* expected-error {{star modifier used outside of function prototype}}16                                                                           expected-error {{array has incomplete element type 'int[]'}}17                                                                         */18  static_assert(1 == _Generic(int[3][2], int[*][2]: 1, int[*][3]: 0));  // expected-error {{star modifier used outside of function prototype}}19  static_assert(1 == _Generic(int[3][n], int[3][*]: 1, int[2][*]: 0));  /* expected-error {{star modifier used outside of function prototype}}20                                                                           expected-error {{array has incomplete element type 'int[]'}}21                                                                         */22  static_assert(1 == _Generic(int[n][m], int[*][*]: 1, char[*][*]: 0)); /* expected-error 2 {{star modifier used outside of function prototype}}23                                                                           expected-error {{array has incomplete element type 'int[]'}}24                                                                         */25  static_assert(1 == _Generic(int(*)[2], int(*)[*]: 1));                // expected-error {{star modifier used outside of function prototype}}26}27 28void questionable() {29  // GCC accepts this despite the * appearing outside of a generic association,30  // but it's not clear whether that's intentionally supported or an oversight.31  // It gives a warning about * being used outside of a declaration, but not32  // with an associated warning group.33  static_assert(1 == _Generic(int[*][*], int[2][100]: 1)); /* expected-error 2 {{star modifier used outside of function prototype}}34                                                              expected-error {{array has incomplete element type 'int[]'}}35                                                            */36  // GCC claims this matches multiple associations, so the functionality seems37  // like it may be intended to work?38  (void)_Generic(int[*][*], /* expected-error 2 {{star modifier used outside of function prototype}}39                               expected-error {{array has incomplete element type 'int[]'}}40                             */41    int[2][100]: 1,42    int[3][1000]: 2,43  );44}45