brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 45cb3d6 Raw
78 lines · cpp
1// RUN: %clang_cc1 -std=c++17 -fopenmp -fsyntax-only -verify %s2 3// This file tests the custom parsing logic for the OpenMP 5.1 attribute4// syntax. It does not test actual OpenMP directive syntax, just the attribute5// parsing bits.6 7// FIXME: the diagnostic here is a bit unsatisfying. We handle the custom omp8// attribute parsing logic when parsing the attribute argument list, and we9// only process an attribute argument list when we see an open paren after the10// attribute name. So this means we never hit the omp-specific parsing and11// instead handle this through the usual Sema attribute handling in12// SemaDeclAttr.cpp, which diagnoses this as an unknown attribute.13[[omp::directive]]; // expected-warning {{unknown attribute 'omp::directive' ignored}}14[[omp::sequence]]; // expected-warning {{unknown attribute 'omp::sequence' ignored}}15[[omp::unknown]]; // expected-warning {{unknown attribute 'omp::unknown' ignored}}16 17[[omp::directive()]]; // expected-error {{expected an OpenMP directive}}18[[omp::sequence()]]; // expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}19 20// Both sequence and directive require an argument list, test that we diagnose21// when the inner directive or sequence is missing its argument list.22[[omp::sequence(directive)]]; // expected-error {{expected '('}}23[[omp::sequence(sequence)]]; // expected-error {{expected '('}}24[[omp::sequence(omp::directive)]]; // expected-error {{expected '('}}25[[omp::sequence(omp::sequence)]]; // expected-error {{expected '('}}26 27// All of the diagnostics here come from the inner sequence and directive not28// being given an argument, but this tests that we can parse either with or29// without the 'omp::'.30[[omp::sequence(directive(), sequence())]]; // expected-error {{expected an OpenMP directive}} expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}31[[omp::sequence(omp::directive(), sequence())]]; // expected-error {{expected an OpenMP directive}} expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}32[[omp::sequence(directive(), omp::sequence())]]; // expected-error {{expected an OpenMP directive}} expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}33[[omp::sequence(omp::directive(), omp::sequence())]]; // expected-error {{expected an OpenMP directive}} expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}34 35// Test that we properly diagnose missing parens within the inner arguments of36// a sequence attribute.37[[omp::sequence( // expected-note {{to match this '('}}38  directive(39)]]; // expected-error {{expected ')'}} expected-error {{expected an OpenMP directive}}40[[omp::sequence( // expected-note {{to match this '('}}41  sequence(42)]]; // expected-error {{expected ')'}} expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}43 44// Test that we properly handle the using attribute syntax.45[[using omp: directive()]]; // expected-error {{expected an OpenMP directive}}46[[using omp: sequence()]]; // expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}47[[using omp: sequence(omp::directive())]]; // expected-error {{expected an OpenMP directive}}48[[using omp: sequence(directive())]]; // expected-error {{expected an OpenMP directive}}49 50// Test that we give a sensible error on an unknown attribute in the omp51// namespace that has an argument list.52[[omp::unknown()]]; // expected-warning {{unknown attribute 'omp::unknown' ignored}}53[[using omp: unknown()]]; // expected-warning {{unknown attribute 'omp::unknown' ignored}}54 55// Test that unknown arguments to the omp::sequence are rejected, regardless of56// what level they're at.57[[omp::sequence(unknown)]]; // expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}58[[omp::sequence(sequence(unknown))]]; // expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}59[[omp::sequence(omp::unknown)]]; // expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}60[[omp::sequence(sequence(omp::unknown))]]; // expected-error {{expected an OpenMP 'directive' or 'sequence' attribute argument}}61 62// FIXME: combining non-openmp attributes with openmp attributes has surprising63// results due to the replay of tokens. We properly parse the non-openmp64// attributes, but we also replay the OpenMP tokens. The attributes then get65// passed to the OpenMP parsing functions and it does not attach the attribute66// to the declaration statement AST node as you might expect. This means that67// the expected diagnostics are not issued. Thankfully, due to the positioning68// of OpenMP attributes and what they appertain to, this should not be a69// frequent issue (hopefully).70int x;71[[deprecated, omp::directive(threadprivate(x))]] int y; // FIXME-expected-note {{'y' has been explicitly marked deprecated here}}72[[omp::directive(threadprivate(x)), deprecated]] int z; // FIXME-expected-note {{'z' has been explicitly marked deprecated here}}73void test() {74  x = 1;75  y = 1; // FIXME-expected-warning {{warning: 'y' is deprecated}}76  z = 1; // FIXME-expected-warning {{warning: 'z' is deprecated}}77}78