Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8460821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:42:46+00:00 2026-06-10T13:42:46+00:00

This compiles when using clang -std=gnu++11 -c test.cpp : void test() { [[random text

  • 0

This compiles when using clang -std=gnu++11 -c test.cpp:

void test() {
    [[random text here]]
    if (0) {
    }
}

But this gives error main.cpp:3:1: error: expected statement:

void test() {
    [[random text here]]
}

If I compile with clang -std=gnu++11 -S -emit-llvm main.cpp and look at the LLVM code it looks like the [[...]] line has no effect:

define void @_Z5testv() nounwind uwtable ssp {
  ret void
}

Any ideas why? bug or some C++11 syntax or GNU extension syntax?

Im using clang from Xcode 4.4.1 (Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:42:47+00:00Added an answer on June 10, 2026 at 1:42 pm

    This is using C++11’s attribute syntax. “random text here” is therefore assumed to be an attribute. By the C++11 specification, an attribute can modify many statements and declarations.

    Attributes can be statements, but they have to actually be statements. Meaning they end in a ; just like many other C++ statements.

    The set of attributes supported by an implementation is implementation-defined (and Clang doesn’t support any. Indeed, it apparently isn’t supposed to support attribute syntax at all, according to the website). Attributes not implemented by a particular implementation should be ignored, which is why it has no effect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a hard time using std::string::iterators in C++. This code compiles fine (still
I am using std::unique_ptr in this piece of code which compiles and runs as
The following code does not compiles using clang 3.0, is this because I have
I have compiled this using Visual Studio 2010 compiler and it has compiler error
When trying to compile this code: #include <iostream> #include <vector> using namespace std; class
How can I get this to compile? The error is when I start using
I am trying to compile the following code using clang but got the following
I'm trying to use the std::shared_ptr in clang++(clang version 3.1 (trunk 143100)) using libstdc++(4.6.1).
I try to compile the following code with clang (version 3.0), but it gives
There is such code: #include <cstdlib> #include <clang-c/Index.h> using namespace std; int main(int argc,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.