
Previously clang AST prints the following declaration: int fun_var_unused() { int x __attribute__((unused)) = 0; return x; } and int __declspec(thread) x = 0; as: int fun_var_unused() { int x = 0 __attribute__((unused)); return x; } and int x = __declspec(thread) 0; which is rejected by C/C++ parser. This patch modifies the logic to print old C attributes for variables as: int __attribute__((unused)) x = 0; and the __declspec case as: int __declspec(thread) x = 0; Fixes: https://github.com/llvm/llvm-project/issues/59973 Previous version: D141714. Differential Revision:https://reviews.llvm.org/D141714
18 lines
521 B
C
18 lines
521 B
C
// This file contain tests for attribute arguments on K&R functions.
|
|
|
|
// RUN: %clang_cc1 -ast-print -x c -std=c89 -fms-extensions %s -o - | FileCheck %s
|
|
|
|
// CHECK: int knr(i)
|
|
// CHECK-NEXT: int i __attribute__((unused));
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: return 0;
|
|
// CHECK-NEXT: }
|
|
int knr(i) int i __attribute__((unused)); { return 0; }
|
|
|
|
// CHECK: __attribute__((unused)) int knr2(i)
|
|
// CHECK-NEXT: int i;
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: return 0;
|
|
// CHECK-NEXT: }
|
|
__attribute__((unused)) int knr2(i) int i; { return 0; }
|