[LLVMbugs] [Bug 14953] New: Can't use __extension__(override) in C++98 to get warning-free C++11 override semantics

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jan 14 12:25:40 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=14953

             Bug #: 14953
           Summary: Can't use __extension__(override) in C++98 to get
                    warning-free C++11 override semantics
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: jwalden+llvm at mit.edu
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Compiling this program:

#if defined(USE_EXTENSION)
#  define MOZ_OVERRIDE  __extension__(override)
#elif defined(USE_PAREN_EXTENSION)
#  define MOZ_OVERRIDE  __extension__ override
#else
#  define MOZ_OVERRIDE  override
#endif

struct X
{
  virtual void foo();
};

struct Y : public X
{
  virtual void foo() MOZ_OVERRIDE;
};

I get these results with clang++:

bar.cpp:16:22: warning: 'override' keyword is a C++11 extension
[-Wc++11-extensions]
  virtual void foo() MOZ_OVERRIDE;
                     ^
bar.cpp:6:25: note: expanded from macro 'MOZ_OVERRIDE'
#  define MOZ_OVERRIDE  override
                        ^
1 warning generated.


These results with -DUSE_EXTENSION:

bar.cpp:16:21: error: expected ';' at end of declaration list
  virtual void foo() MOZ_OVERRIDE;
                    ^
                    ;
1 error generated.

And these results with -DUSE_PAREN_EXTENSION:

bar.cpp:16:21: error: expected ';' at end of declaration list
  virtual void foo() MOZ_OVERRIDE;
                    ^
                    ;
1 error generated.

__has_extension(cxx_override_control) is true in C++98 and unfortunately
doesn't imply override control works without warnings.  It would be nice to be
able to selectively use override/final in an (abstracting) macro in C++98
without warnings.  (That is, sanction use of override as long as it's through
one macro using __extension__, but not if it's written out as if override were
standard in C++98.)  espindola says he thinks parens or no-parens should
probably work; I have no preference between them.  Making __has_extension only
return true if support is warning-free would also work for me, although this
may be a no-go for violating __has_extension's traditional semantics.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list